Segers-Ian
Segers-Ian

Reputation: 1067

Integration Tests with Docker and Bitbucket pipelines

I would like to run my integration tests as a part of the Bitbucket pipelines CI. My integration tests test a NodeJS backend that runs against an empty MongoDB database. To enable this I want to create a Docker Image that Bitbucket pipelines can pull from a docker image repository.

My bitbucket-pipelines.yml will be something like:

image: <my image with nodejs and a mongodb linked to it>
pipelines:
  default:
    - step:
        script:
          - npm test

Now I only need to create a docker image with nodejs and mongodb configured properly. I am able to build an environment by creating the following docker-compose.yml file:

version: "2"
services:
  web:
    build: .
    volumes:
      - ./:/app
    ports:
      - "3000:3000"
      - "9090:8080"
    links:
     - mongo
  mongo:
   image: mongo
   ports:
    - "27018:27017"

My Dockerfile:

FROM node:7.9
RUN mkdir /app
WORKDIR /app
COPY package.json /app
RUN npm install
COPY . /app
EXPOSE 3000
CMD ["npm", "run", "dev"]

Problem - Question

I can run locally with docker compose my environment, but how can I make a single image, instead of using docker compose so I can publish that image publicly for using it in my Bitbucket CI? I am still fresh to docker, but I already understood from the documentation that trying to install MongoDB on top of my nodeJS image is a red flag.

Upvotes: 2

Views: 3282

Answers (1)

Michael Willemse
Michael Willemse

Reputation: 195

Bitbucket Pipeline doesn't have native support for docker compose yet.

However you can define up to 3 services in the bitbucket-pipelines.yml. Documentation available at: https://confluence.atlassian.com/bitbucket/service-containers-for-bitbucket-pipelines-874786688.html

Upvotes: 3

Related Questions