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

Use pre-built images for nginx & service containers #895

Open
wants to merge 95 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 77 commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
3ea7fed
ci: move to GHA; only run ghcr build on test pass AND when tagged
Jan 29, 2025
fc12898
fix shellcheck?
Jan 29, 2025
4b71f94
fix docker-compose build context
Jan 29, 2025
1a628d7
volume paths
Jan 29, 2025
46d2e17
ci: comment out working stuff
Jan 29, 2025
cde1280
service.dockerfile: separate unrelated commands
Jan 29, 2025
f9bb335
fix runner name
Jan 29, 2025
fb8e409
check path with available tools
Jan 29, 2025
1850615
1..timeout
Jan 30, 2025
ae7d2c9
for inc loop
Jan 30, 2025
6cf7ab9
store result before testing
Jan 30, 2025
12845ff
less subprocess
Jan 30, 2025
67b46a3
store res correct
Jan 30, 2025
d93db3d
remove circle config
Jan 30, 2025
cbadcde
get container name
Jan 30, 2025
4021da7
fix syntax hilighting
Jan 30, 2025
255cffc
no container: prefix
Jan 30, 2025
0c775f0
start container before getting name
Jan 30, 2025
69e78f3
rename var
Jan 30, 2025
3e32f1d
exec
Jan 30, 2025
f65e7f4
add logging
Jan 30, 2025
798dddc
remove noisy x
Jan 30, 2025
6a213fe
restructure
Jan 30, 2025
5cb2235
update check regex
Jan 30, 2025
11cb7a8
clearer code
Jan 30, 2025
ae5c3ea
remove nginxContainer var
Jan 30, 2025
cbc2970
test images
Jan 30, 2025
213d2f9
add docker compose logs
Jan 30, 2025
d868b92
X
Jan 30, 2025
0a006ae
or true?
Jan 30, 2025
acc1147
use a temp file
Jan 30, 2025
02fd5b1
single line
Jan 30, 2025
1f9a31e
redirect to stdout
Jan 30, 2025
f4b4456
run it
Jan 30, 2025
f20b090
log spacing
Jan 30, 2025
cdbefa0
show pm2 before count
Jan 30, 2025
4fe3ab6
8
Jan 30, 2025
63faeef
expect 4
Jan 30, 2025
ef321d9
enable all jobs
Jan 30, 2025
ba1f34d
clearer logging, comments
Jan 30, 2025
d09653e
docker-compose: use published images
Jan 30, 2025
9f190bd
use snapshots but not for root docker-compos
Jan 30, 2025
0dfed52
use both docker-compose files
Jan 30, 2025
9c85d21
ci: add TODO
Jan 30, 2025
8a54f30
fix compose file order
Jan 30, 2025
12e7ab8
fix context
Jan 30, 2025
ba309a5
remove explicit context
Jan 30, 2025
e9c8398
ghcr: show expected tag
Jan 30, 2025
3bcb62c
run ghcr job
Jan 30, 2025
dbdb893
docker run
Jan 30, 2025
fea2130
try execute?
Jan 30, 2025
9241ef1
try wider conditionsal
Jan 30, 2025
bb5a230
comment
Jan 30, 2025
660d375
comment out test yml
Jan 30, 2025
20580f9
print event name
Jan 30, 2025
86a263a
move test yml out the way
Jan 30, 2025
e6e20cc
fix yml
Jan 30, 2025
7cb5681
more devbug - tags etc
Jan 30, 2025
2e515d9
remove TODO
Jan 30, 2025
d49c273
no need
Jan 30, 2025
b26af10
ref type
Jan 30, 2025
16f40d0
try check only on tag
Jan 30, 2025
2d5d2be
ref_type
Jan 30, 2025
f51b8ac
simplify if the second half runs
Jan 30, 2025
9a3fd05
reinstate tings
Jan 30, 2025
4a4ac7e
reinstate test
Jan 30, 2025
9b8194e
revert dockerfile changes
Jan 30, 2025
69a915c
don't build on master
Jan 30, 2025
2747301
run test on tag
Jan 30, 2025
08893b7
expicitly run on tags
Jan 30, 2025
c3f255a
more restruct
Jan 30, 2025
75e711c
Testing build triggers
alxndrsn Jan 30, 2025
851adbc
rebuild
Jan 30, 2025
f1415df
Merge branch 'next' into another-try
Feb 14, 2025
b48180e
build on pushes (check it still builds on tags...)
Feb 14, 2025
a7e5518
simplify/revert yaml
Feb 14, 2025
6e01960
Add debug job
Feb 14, 2025
e653b26
fix yaml?
Feb 14, 2025
d66ac83
stub out test jobs
Feb 14, 2025
ee1a2ad
remove rebuild
Feb 14, 2025
1fc807b
Add make release target
Feb 14, 2025
acee5d5
Revert "Add make release target"
Feb 14, 2025
08b6d82
import ghcr into test
Feb 14, 2025
d0938ba
remove ghcr workflow
Feb 14, 2025
9abf42c
re-intro standard CI
Feb 14, 2025
97cf732
remove extra permissiosn
Feb 14, 2025
5750c0a
add tag check
Feb 14, 2025
08d168a
add release script
Feb 14, 2025
814d416
add release script
Feb 14, 2025
f5dc805
tweak script
Feb 14, 2025
0b22c62
shellcheck
Feb 14, 2025
ed2c141
ci: rename check-image-references job
Feb 14, 2025
6e05a50
Merge branch 'next' into another-try
alxndrsn Feb 20, 2025
c693163
use existing version
Feb 20, 2025
1fc0e68
Merge branch 'next' into another-try
alxndrsn Feb 28, 2025
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
34 changes: 32 additions & 2 deletions .github/workflows/ghcr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,45 @@ name: GHCR

on:
workflow_dispatch:
push:
branches: [master]
# See: https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#workflow_run
workflow_run:
workflows: [Test]
types: [completed]
tags: ["v*.*.*"]

env:
REGISTRY: ghcr.io

jobs:
debug:
steps:
run: 'echo "github.event_name: [ ${{ github.event_name }} ]"'
run: 'echo "github.event.workflow_run.conclusion: [ ${{ github.event.workflow_run.conclusion }} ]"'
run: "echo 'condition: [ ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }} ]'"
check-images-are-used:
# Only run this job if tests pass, or this workflow was triggered manually.
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
image: [nginx, service]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/central-${{ matrix.image }}
- name: "Checking release image is referenced in docker-compose.yml..."
if: ${{ github.ref_type == 'tag' }}
run: 'grep "${{ steps.meta.outputs.tags }}" docker-compose.yml'

build-push-image:
needs: check-images-are-used
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down
8 changes: 2 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ services:
- DKIM_KEY_PATH=/etc/exim4/dkim.key.temp
restart: always
service:
build:
context: .
dockerfile: service.dockerfile
image: 'ghcr.io/getodk/central-service:2025.1'
depends_on:
- secrets
- postgres14
Expand Down Expand Up @@ -79,9 +77,7 @@ services:
logging:
driver: local
nginx:
build:
context: .
dockerfile: nginx.dockerfile
image: 'ghcr.io/getodk/central-nginx:2025.1'
depends_on:
- service
- enketo
Expand Down
Empty file added rebuild
Empty file.
7 changes: 7 additions & 0 deletions test/snapshots.docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
services:
service:
build:
dockerfile: service.dockerfile
nginx:
build:
dockerfile: nginx.dockerfile
15 changes: 11 additions & 4 deletions test/test-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ set -o pipefail

log() { echo >&2 "[$(basename "$0")] $*"; }

docker_compose() {
docker compose \
--file docker-compose.yml \
--file test/snapshots.docker-compose.yml \
"$@"
}

tmp="$(mktemp)"

check_path() {
Expand All @@ -13,7 +20,7 @@ check_path() {
for (( i=0; ; ++i )); do
log "Checking response from $requestPath ..."
echo -e "GET $requestPath HTTP/1.0\r\nHost: local\r\n\r\n" |
docker compose exec --no-TTY nginx \
docker_compose exec --no-TTY nginx \
openssl s_client -quiet -connect 127.0.0.1:443 \
>"$tmp" 2>&1 || true
if grep --silent --fixed-strings "$expected" "$tmp"; then
Expand Down Expand Up @@ -43,10 +50,10 @@ SYSADMIN_EMAIL=no-reply@getodk.org' > .env
touch ./files/allow-postgres14-upgrade

log "Building docker containers..."
docker compose build
docker_compose build

log "Starting containers..."
docker compose up --detach
docker_compose up --detach

log "Verifying frontend..."
check_path 30 / 'ODK Central'
Expand All @@ -57,7 +64,7 @@ check_path 2 /v1/projects '[]'
log " Backend started OK."

log "Verifying pm2..."
docker compose exec service npx pm2 list | tee "$tmp"
docker_compose exec service npx pm2 list | tee "$tmp"
processCount="$(grep --count online "$tmp")"
if [[ "$processCount" != 4 ]]; then
log "!!! PM2 returned an unexpected count for online processes."
Expand Down