Example for machine parameter migrating CircleCI 1 to 2

circle.yml
2.0

#1

How can i write this circle 1 config to 2:

machine:
  java:
      version: oraclejdk8
  ruby:
    version: 2.4.1
  services:
    - redis
    - rabbitmq-server

Do i need to use apt-get (Use run steps) to fulfill these?


#2

You can use apt-get to install services you want, but the recommended way (at least for the Docker executor) is to spin up a predefined image for each. So in your case you would probably have a Java image as your primary build image/container and Redis and RabbitMQ as secondary images/containers.

I don’t use Machine so can’t advise on that. From the docs it does not seem that you can spin up secondary containers natively. Do you actually need Machine? In general, Docker seems to be recommended by the documentation.

Finally, you can use Docker Compose (probably in either executor). This is a bit more faff to set up, but it allows you to run your tests/build locally in a mostly identical environment to CircleCI. I do this, and sometimes run my integration tests locally after a big change, in order to see whether another fix is required before pushing.


#3

I also figured same. Converted machine to docker execution with below config:

    docker:
      - image: circleci/ruby:2.4.1-stretch-browsers
      - image: circleci/postgres:9.4-alpine
        environment:
          POSTGRES_USER: ubuntu
          POSTGRES_DB: circle_test
      - image: circleci/rabbitmq
      - image: circleci/redis:3-alpine
      - image: elasticsearch:5-alpine

#4

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