ci: Add GitLab CI/CD pipeline for container builds

Builds and pushes container images to GitLab Container Registry
when version tags (v*.*.*) are pushed.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-23 19:59:41 -07:00
parent 9c65723e9d
commit e97b778cb7

40
.gitlab-ci.yml Normal file
View File

@@ -0,0 +1,40 @@
# GitLab CI/CD Pipeline for StarPunk
# Builds and pushes container images on version tags
stages:
- build
variables:
# Required for Docker-in-Docker
DOCKER_TLS_CERTDIR: "/certs"
# Use overlay2 driver for better performance
DOCKER_DRIVER: overlay2
# Build and push container image
build-container:
stage: build
image: docker:24
services:
- docker:24-dind
# Only trigger on version tags (e.g., v0.9.5, v1.0.0)
rules:
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/
before_script:
# Login to GitLab Container Registry
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script:
# Build the container image with both version and latest tags
- |
docker build \
--tag $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG \
--tag $CI_REGISTRY_IMAGE:latest \
--file Containerfile \
.
# Push both tags to the registry
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
- docker push $CI_REGISTRY_IMAGE:latest
# Cache Docker layers between builds
cache:
key: docker-$CI_COMMIT_REF_SLUG
paths:
- .docker-cache