Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First implementation of a deployment via docker compose #894

Merged
merged 2 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .deploy/ghcr.io/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
IMAGE_TAG=latest

HTTP_FORWARDED_COUNT=2
4 changes: 4 additions & 0 deletions .deploy/ghcr.io/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
services:
patient-web:
build: !reset null
image: ghcr.io/infoderm/patients:${IMAGE_TAG}
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ PORT=3000

MONGO_VERSION=5.0
MONGO_URL=mongodb://patient-db:27017/meteor

HTTP_FORWARDED_COUNT=1
81 changes: 81 additions & 0 deletions .github/workflows/ci:test:deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: ci:test:deploy

on:
push:
branches:
- main
pull_request:
merge_group:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:

build:
name: Continuous integration (test deploy)
strategy:
matrix:
platform:
- ubuntu-latest

runs-on: ${{ matrix.platform }}

timeout-minutes: 4

steps:
- name: Checkout 🛎️
uses: actions/checkout@v4

- name: Wait for image build workflow to succeed
uses: ArcticLampyrid/[email protected]
with:
workflow: ci:build:image.yml
sha: ${{ github.sha }}

- name: Log in to GitHub Packages registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ github.token }}

- name: Start
env:
ROOT_URL: http://localhost
IMAGE_TAG: sha-${{ github.sha }}
run: |
docker compose \
--env-file .env -f compose.yaml \
--env-file .deploy/ghcr.io/.env -f .deploy/ghcr.io/compose.yaml \
up --no-build --detach

- name: Wait for database container to be healthy
run: |
timeout 60 bash -c \
'until docker inspect --format "{{json .State.Health }}" "$(docker compose ps -q patient-db)" | jq -e ".Status == \"healthy\"" ; do sleep 1; done'

- name: Wait for web port to be available
run: |
timeout 60 bash -c \
'until nc -z -v -w5 127.0.0.1 3000 ; do sleep 1; done'

- name: Wait for web container to be healthy
run: |
timeout 60 bash -c \
'until docker inspect --format "{{json .State.Health }}" "$(docker compose ps -q patient-web)" | jq -e ".Status == \"healthy\"" ; do sleep 1; done'

- name: Call healthcheck endpoint
run: |
timeout 60 bash -c \
'curl -f http://localhost:3000/api/healthcheck'

- name: Run healthcheck script
run: |
timeout 60 bash -c \
'node scripts/healthcheck.cjs http://localhost:3000/api/healthcheck'

- name: Stop
run: |
docker compose down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,16 @@ Install dependencies, custom certificates, and MongoDB on server:

TAG=vYYYY.MM.DD meteor npm run deploy

#### Generate a Docker `compose` configuration

:construction: This is work in progress. :construction:

ROOT_URL=https://example.local IMAGE_TAG=v1 \
docker compose \
--env-file .env -f compose.yaml \
--env-file .deploy/ghcr.io/.env -f .deploy/ghcr.io/compose.yaml \
config

## :recycle: Backup & Restore

The current backup system requires `age` and the encryption/decryption key at
Expand Down
1 change: 1 addition & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ services:
- ROOT_URL=${ROOT_URL}
- PORT=${PORT}
- MONGO_URL=${MONGO_URL}
- HTTP_FORWARDED_COUNT=${HTTP_FORWARDED_COUNT}
depends_on:
patient-db:
condition: service_healthy
Expand Down
Loading