Skip to content
This repository has been archived by the owner on Jan 28, 2024. It is now read-only.

Commit

Permalink
ci: add docker-compose test job
Browse files Browse the repository at this point in the history
  • Loading branch information
Frazer Smith committed Dec 23, 2020
1 parent 644cd3b commit 3e4e9ad
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
20 changes: 16 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ jobs:
- name: Run License Checker
run: yarn license-checker

build:
name: Build
unittests:
name: Unit Tests
if: github.event.pull_request.draft == false
strategy:
matrix:
Expand All @@ -56,9 +56,21 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel: true

dockercomposetests:
name: Docker Compose Build Tests
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build and Deploy App
run: |
cp .env.template .env.test
NODE_ENV=test docker-compose up --detach
# run: docker run --network container:obfuscation-service appropriate/curl -s --retry 10 --retry-connrefused 'http:https://localhost:8204?patient=https://fhir.nhs.uk/Id/nhs-number|9449304513&birthdate=1934-10-23&location=https://fhir.nhs.uk/Id/ods-organization-code|RA4&practitioner=https://sider.nhs.uk/auth|[email protected]'

coverage:
name: Aggregate Coverage Calculations
needs: build
needs: unittests
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
Expand All @@ -69,7 +81,7 @@ jobs:

automerge:
name: Automatically merge Dependabot pull requests
needs: [lint, build]
needs: [lint, unittests, dockercomposetests]
runs-on: ubuntu-latest
steps:
- uses: fastify/github-action-merge-dependabot@v1
Expand Down
12 changes: 5 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@ FROM node:lts-alpine
ARG NODE_ENV
ENV NODE_ENV=${NODE_ENV}

# Update and upgrade packages
# Update and upgrade image packages
RUN apk -U upgrade

# Create unprivileged user to run app and prevent
# privilege escalation attacks
RUN addgroup -S appgroup && adduser -S appuser -G appgroup

WORKDIR /usr/app
WORKDIR /usr/src/app
RUN mkdir logs && chown -R appuser:appgroup logs
COPY package.json .
COPY yarn.lock .
COPY .env.${NODE_ENV} .
COPY ./src ./src

COPY . .
# If appropriate env file missing, use template
RUN cp .env.template .env.${NODE_ENV}
# git needed to install node modules from github
RUN apk add --no-cache git

Expand Down
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
version: '3.8'
services:
app:
container_name: obfuscation-service
build:
args:
NODE_ENV: production
NODE_ENV: $NODE_ENV
context: .
env_file: .env.production
env_file: .env.${NODE_ENV}
ports:
- 127.0.0.1:${PORT:-8204}:${PORT:-8204}

0 comments on commit 3e4e9ad

Please sign in to comment.