From 6f22e11484705b9a120ab075c358a2c4584f1049 Mon Sep 17 00:00:00 2001 From: Joel Whalen Date: Wed, 14 Feb 2024 13:24:10 -0500 Subject: [PATCH] feat: add docker compose example for pact consumer --- Dockerfile | 22 ++++++++++++++++++++++ docker-compose.yml | 31 +++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..4792c369 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +ARG NODE_VERSION=20.11 + +FROM node:${NODE_VERSION} + +WORKDIR /test + +COPY package.json package.json +COPY package-lock.json package-lock.json +COPY .env .env +COPY Makefile Makefile +RUN npm install + +COPY src src +# Allow github actions to write to this directory +RUN mkdir pacts +RUN chmod 777 pacts + +ENV HOME /home/node +USER node + + +CMD ["make", "test"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..ee12f5a7 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,31 @@ +version: '3.6' +services: + example-consumer: + build: + context: ./ + environment: + REACT_APP_API_BASE_URL: http://localhost:8080 + volumes: + - pacts_data:/test/pacts + # command: tail -f /dev/null + command: make test + platform: linux/amd64 + + pact-broker-cli: + image: pactfoundation/pact-cli:latest-multi + platform: linux/amd64 + depends_on: + - example-consumer + environment: + PACT_BROKER_BASE_URL: ${PACT_BROKER_BASE_URL} + PACT_BROKER_TOKEN: ${PACT_BROKER_TOKEN} + PACT_CONSUMER_BRANCH: ${PACT_CONSUMER_BRANCH} + PACT_CONSUMER_APP_VERSION: ${PACT_CONSUMER_APP_VERSION} + volumes: + - pacts_data:/pact/pacts + # command: tail -f /dev/null + command: | + pact-broker publish pacts --branch=$PACT_CONSUMER_BRANCH --consumer-app-version=$PACT_CONSUMER_APP_VERSION + +volumes: + pacts_data: \ No newline at end of file