Skip to content

Add smoke test and healthcheck to docker build #590

Add smoke test and healthcheck to docker build

Add smoke test and healthcheck to docker build #590

Workflow file for this run

name: CI
on:
push:
branches: [main]
tags: ['v*']
pull_request:
types: [synchronize, opened, reopened]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 22.x
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- run: pnpm codegen --check
- run: pnpm build
- run: pnpm lint
- run: pnpm test
build-docker:
runs-on: ubuntu-latest
env:
REGISTRY_USERNAME: 'nlsoftware'
REGISTRY_IMAGE: nlsoftware/navigate-configs
steps:
- uses: actions/checkout@v4
- name: Log in to the Container registry
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: docker/login-action@v3
with:
username: ${{ env.REGISTRY_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
id: build
with:
context: .
# Only push on releases
push: ${{ startsWith(github.ref, 'refs/tags/v') }}
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Smoke test
run: |
echo "Smoke test for version ${CONFIGS_VERSION}"
docker compose -f .github/docker-compose.yml up -d
curl --connect-timeout 5 --max-time 10 --retry 5 --retry-delay 0 --retry-max-time 40 --retry-all-errors -H 'apollo-require-preflight: true' 'http://localhost:4000?query=%7B__typename%7D'
echo "Smoke test successful!"
docker compose -f .github/docker-compose.yml down
env:
CONFIGS_VERSION: ${{ steps.meta.outputs.version }}
DB_USER: jimmy
DB_PASS: banana
DB_NAME: configs