Files
ETPlot/.gitlab-ci.yml
T
lars 8cae6533d5 Replace Singularity with Docker; add production deployment setup
- Remove Singularity.def; add Dockerfile (python:3.11-slim + ImageMagick,
  non-root user, installs gallery package with dev extras)
- Add .dockerignore to keep image lean
- Rewrite .gitlab-ci.yml: build→test→publish stages using Docker-in-Docker;
  push per-commit SHA tag and promote to :latest on main
- Add docker-compose.yml: gallery-generator + nginx services sharing a
  named volume; configurable GENERATE_INTERVAL env var
- Add deploy/nginx.conf: gzip, security headers, correct caching policy
  (immutable for assets, no-store for HTML)
- Add deploy/entrypoint.sh: runs gallery generate on startup then loops
  on GENERATE_INTERVAL; exits cleanly when interval is 0

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-29 11:48:04 +02:00

100 lines
2.4 KiB
YAML

# GitLab CI/CD Pipeline for ETPlot
# Builds a Docker image and runs tests inside it.
stages:
- build
- test
- publish
variables:
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
IMAGE_LATEST: $CI_REGISTRY_IMAGE:latest
# ---------------------------------------------------------------------------
# Build
# ---------------------------------------------------------------------------
build:image:
stage: build
image: docker:27
services:
- docker:27-dind
variables:
DOCKER_TLS_CERTDIR: "/certs"
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
script:
- docker build --pull -t "$IMAGE_TAG" .
- docker push "$IMAGE_TAG"
rules:
- if: $CI_COMMIT_BRANCH
# ---------------------------------------------------------------------------
# Test
# ---------------------------------------------------------------------------
.test_base:
stage: test
image: docker:27
services:
- docker:27-dind
variables:
DOCKER_TLS_CERTDIR: "/certs"
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
- docker pull "$IMAGE_TAG"
needs:
- build:image
test:pytest:
extends: .test_base
script:
- docker run --rm -w /app "$IMAGE_TAG" python -m pytest tests/ -v
artifacts:
when: always
expire_in: 30 days
test:coverage:
extends: .test_base
script:
- |
docker run --rm -w /app \
-v "$CI_PROJECT_DIR:/artifacts" \
"$IMAGE_TAG" \
python -m pytest tests/ \
--cov=gallery \
--cov-report=xml:/artifacts/coverage.xml \
--cov-report=term
coverage: '/TOTAL.*\s+(\d+%)$/'
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
paths:
- coverage.xml
expire_in: 30 days
# ---------------------------------------------------------------------------
# Publish latest tag on main
# ---------------------------------------------------------------------------
publish:latest:
stage: publish
image: docker:27
services:
- docker:27-dind
variables:
DOCKER_TLS_CERTDIR: "/certs"
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
script:
- docker pull "$IMAGE_TAG"
- docker tag "$IMAGE_TAG" "$IMAGE_LATEST"
- docker push "$IMAGE_LATEST"
needs:
- test:pytest
- test:coverage
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH