restore normal gitlab ci

This commit is contained in:
Graham McIntire 2026-02-08 10:56:06 -06:00
parent 90e89641b7
commit 96c0254ab6
No known key found for this signature in database

View file

@ -3,12 +3,9 @@ stages:
- deploy
variables:
# Nix configuration
NIX_CONFIG: |
experimental-features = nix-command flakes
substituters = https://cache.nixos.org https://towerops.cachix.org
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= towerops.cachix.org-1:YOUR_PUBLIC_KEY_HERE
CACHIX_CACHE: "towerops"
DOCKER_BUILDKIT: 1
CI_BUILDX_ARCHS: "linux/amd64"
DOCKER_TLS_CERTDIR: ""
workflow:
auto_cancel:
@ -18,42 +15,23 @@ build:
stage: build
interruptible: true
tags:
- nix # Requires GitLab Runner with Nix installed
image: nixos/nix:latest
- home
image: docker:27
services:
- docker:27-dind
before_script:
# Install Docker for loading and pushing images
- nix-env -iA nixpkgs.docker
# Install Cachix if auth token is available
- |
if [ -n "$CACHIX_AUTH_TOKEN" ]; then
nix-env -iA cachix -f https://cachix.org/api/v1/install
echo "$CACHIX_AUTH_TOKEN" | cachix authtoken
fi
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script:
# Build Docker image with Nix
- echo "Building Docker image with Nix..."
- nix build .#dockerImage --print-build-logs
# Push build artifacts to Cachix for faster future builds
- |
if [ -n "$CACHIX_AUTH_TOKEN" ]; then
echo "Pushing build artifacts to Cachix..."
nix path-info --json .#dockerImage | jq -r '.[].path' | cachix push $CACHIX_CACHE
fi
# Load image into Docker
- echo "Loading Docker image..."
- docker load < result
# Tag image with commit SHA and latest
- docker tag $(docker images -q | head -1) $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
- docker tag $(docker images -q | head -1) $CI_REGISTRY_IMAGE:latest
# Login to GitLab Container Registry
- echo "$CI_REGISTRY_PASSWORD" | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
# Push to registry
- echo "Pushing to GitLab Container Registry..."
# Pull latest image for layer caching (ignore failures if not exists)
- docker pull $CI_REGISTRY_IMAGE:latest || true
# Build with cache-from for faster builds and inline cache for future builds
- docker build
--cache-from $CI_REGISTRY_IMAGE:latest
--build-arg BUILDKIT_INLINE_CACHE=1
-f k8s/Dockerfile
-t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
-t $CI_REGISTRY_IMAGE:latest
.
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
- docker push $CI_REGISTRY_IMAGE:latest
rules: