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