How to use a rabbitmq definitions file inside a docker container in circleci?

Viewed 130

I'm using a definitions.json file to define user and queue configurations for rabbitmq. When I create a docker image, I add this file as a volume:

    services:
      rabbitmq:
        image: rabbitmq:3.8.16-management-alpine
        container_name: 'rabbitmq'
        ports:
          - 5672:5672
          - 15672:15672
        networks:
          - XXX
        volumes:
          - ./conf/rabbitmq-definitions.json:/etc/rabbitmq/definitions.json:ro

However, looking at circleci documentation, it seems like you cannot mount a volume in circleci. Is there any other way I can add the definitions file to make it work with circleci as well?

1 Answers

What executor type are you using? You can definitely use volumes in CircleCI if you use machine executor instead of docker executor. I use machine executors for my integration tests when I need to do a docker run or a docker-compose. I don't have a docker-compose example handy, as I have workflows that use docker-compose but without volumes. I do have multiple workflows that use the machine executor and execute the docker run command mounting specific folders from the workspace as volumes. So your job will look something like below:

integration_test:
  machine:
    image: ubuntu-2004:202010-01
  steps:
    - checkout
    - attach_workspace:
        at: ~/my-app
    - run: |
        make functional-test

You can find a sample machine executor job here and a test that gets executed when make functional-test is called where it performs a docker run with volumes here

Related