diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..efb3eb9 --- /dev/null +++ b/.gitlab-ci.yml @@ -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