Add container readiness checks and exclude local state from images
Adapted from MikaelKW/nodecast-tv-plus readiness and container context work. Co-authored-by: MikaelKW <87399352+MikaelKW@users.noreply.github.com>
This commit is contained in:
39
.github/workflows/container.yml
vendored
Normal file
39
.github/workflows/container.yml
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
name: Container Smoke Test
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths: [Dockerfile, .dockerignore, 'server/**', scripts/healthcheck.cjs, 'package*.json', .github/workflows/container.yml]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
container:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- name: Build and check readiness
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p data
|
||||
printf 'build context sentinel' > .env.container-sentinel
|
||||
printf 'build context sentinel' > data/container-sentinel
|
||||
docker build -t nodecast-smoke .
|
||||
docker run -d --name nodecast-smoke nodecast-smoke
|
||||
for attempt in $(seq 1 60); do
|
||||
if docker exec nodecast-smoke node scripts/healthcheck.cjs; then
|
||||
docker exec nodecast-smoke sh -c 'test ! -e /app/.env.container-sentinel && test ! -e /app/data/container-sentinel'
|
||||
exit 0
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
docker logs nodecast-smoke
|
||||
exit 1
|
||||
- name: Show container logs on failure
|
||||
if: failure()
|
||||
run: docker logs nodecast-smoke || true
|
||||
- name: Remove smoke container
|
||||
if: always()
|
||||
run: docker rm -f nodecast-smoke || true
|
||||
Reference in New Issue
Block a user