Multiple docker image on circle ci 2.0

docker
config

#1

I am looking for help on how to set up my config.yml on circle ci 2.0

I need to have multiple images (one nodejs, and one openjdk as well as a chrome one in order to run karma js tests).

I will therefore need to run commands on several of the docker containers. Can someone please advise?

Here is my current config (it only deals with the java part):

version: 2
jobs:
  build:
    docker:
      - image: openjdk:8
        environment:
          _JAVA_OPTIONS: "-Xms512m -Xmx1024m"
    working_directory:  ~/bignibou
    steps:
      - checkout
      - run: ./gradlew :bignibou-server:check

Can someone please help?


#2
build:
    docker:
      - image: docker:1.13.1-git
      - image: mongo:3.4.3

- run: |
          docker run -d -h mongo-master --name mongo-master mongo:3.4.3

And link to you build image…


#3

Build one image if they all need to be run at once. Otherwise the multiple job support should help:

https://circleci.com/docs/2.0/defining-multiple-jobs/


#4

Hello Rohara,

I tried to implement a multiple job config as follows:

version: 2
jobs:

  build_client:
    docker:
      - image: node:6.9.5
    working_directory:  ~/bignibou
    steps:
      - checkout
      - run: (cd bignibou-client && npm install)

  test_client:
     docker:
       - image: circleci/node:6.10-browsers
     working_directory:  ~/bignibou
     steps:
      - run:
          name: Starting Xvfb (for Browser Tests)
          command: Xvfb :99 -screen 0 1280x1024x24
          background: true
      - run: (cd bignibou-client && node_modules/.bin/ng test --watch=false)

  build_server:
    docker:
      - image: openjdk:8
        environment:
          _JAVA_OPTIONS: "-Xms512m -Xmx1024m"
    working_directory:  ~/bignibou
    steps:
      - checkout
      - run: ./gradlew :bignibou-server:check :bignibou-server:assemble

  build:
    docker:
      - image: openjdk:8
        environment:
          _JAVA_OPTIONS: "-Xms512m -Xmx1024m"
    working_directory:  ~/bignibou
    steps:
      - checkout
      - run: bash .circleci/run-jobs.sh

Here is my run-jobs.sh:

#!/usr/bin/env bash

curl -u ${CIRCLE_API_TOKEN}: \
     -d build_parameters[CIRCLE_JOB]=build_client \
     https://circleci.com/api/v1.1/project/github/myOrg/bignibou/tree/$CIRCLE_BRANCH

curl -u ${CIRCLE_API_TOKEN}: \
     -d build_parameters[CIRCLE_JOB]=test_client \
     https://circleci.com/api/v1.1/project/github/myOrg/bignibou/tree/$CIRCLE_BRANCH

curl -u ${CIRCLE_API_TOKEN}: \
     -d build_parameters[CIRCLE_JOB]=build_server \
     https://circleci.com/api/v1.1/project/github/myOrg/bignibou/tree/$CIRCLE_BRANCH

I get a sucessfull status for my build but nothing happens…

Here is the partial output from the build:

{
  "compare" : null,
  "previous_successful_build" : {
    "build_num" : 570,
    "status" : "success",
    "build_time_millis" : 61202
  },
  "build_parameters" : {
    "CIRCLE_JOB" : "build_client"
  },
  "oss" : false,
  "committer_date" : null,
  "body" : null,
  "usage_queued_at" : "2017-05-05T11:24:57.162Z",
  "fail_reason" : null,
  "retry_of" : null,
  "reponame" : "bignibou",
  "ssh_users" : [ ],
  "build_url" : "https://circleci.com/gh/myOrg/bignibou/574",
  "parallel" : 2,
  "failed" : null,
  "branch" : "circle-ci-2-migration",
  "username" : "myOrg",
  "author_date" : null,
  "why" : "api",
  "user" : {
    "is_user" : true,
    "login" : "myLogin",
    "avatar_url" : "https://avatars2.githubusercontent.com/u/922340?v=3",
    "name" : null,
    "vcs_type" : "github",
    "id" : 922340
  },
  "vcs_revision" : "451ccc1170a775409476b9e23b198b3e08651c54",
  "vcs_tag" : null,
  "build_num" : 574,
  "infrastructure_fail" : false,
  "committer_email" : null,
  "previous" : {
    "build_num" : 573,
    "status" : "running",
    "build_time_millis" : 0
  },
  "status" : "not_running",
  "committer_name" : null,
  "retries" : null,
  "subject" : null,
  "vcs_type" : "github",
  "timedout" : false,
  "dont_build" : null,
  "lifecycle" : "not_running",
  "no_dependency_cache" : false,
  "stop_time" : null,
  "ssh_disabled" : true,
  "build_time_millis" : null,
  "picard" : null,
  "circle_yml" : null,
  "messages" : [ ],
  "is_first_green_build" : false,
  "job_name" : null,
  "start_time" : null,
  "canceler" : null,
  "platform" : "2.0",
  "outcome" : null,
  "vcs_url" : "https://github.com/myOrg/bignibou",
  "author_name" : null,
  "node" : null,
  "canceled" : false,
  "author_email" : null
}

Can you please help?


#5

Hello unfii,
Thanks for your reply. Can you please explain the solution you suggest?
Regards,


#6

You just need to pass -XPOST to curl to prevent it from being a GET request.


#7

@rohara

I have changed to POST instead of GET.

However it just occurred to me that the working_directory: ~/bignibou
does not point to the same directory… Just to directories with the same name on different docker containers… Can you confirm that please?

Then how can I use the result of the build output from build_client in build_server? In other words, the server requires the output from the client build.

Thanks in advance,


#8

It’s /root/bignibou on most Docker images, but our CircleCI images would land you in /home/circleci/bignibou.


#9

Ummm. I am not sure I understand: are the three directories actually one and the same or three directories with the same name on three different containers?


#10

Can you please also help me with this:

Regards,


#11

The latter. Each container is a different environment. While the name of the directory is the same, and the path to the directory is the same, they are not referencing the same inodes.


#12

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.