Skip to content

Commit af85060

Browse files
committed
Merge remote-tracking branch 'gitlab/master'
2 parents 98dc629 + 4df1e76 commit af85060

1 file changed

Lines changed: 79 additions & 0 deletions

File tree

.gitlab-ci.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Shared GitLab CI pipeline template for apps using the common Dockerfile
2+
# pattern (bun-based Next.js, multi-stage, NEXT_PUBLIC_* ARGs, port 3000).
3+
#
4+
# This is the GitLab equivalent of docs/app-build-workflow-template.yml
5+
# (the GitHub Actions workflow it replaces).
6+
#
7+
# USAGE
8+
#
9+
# 1. In each app repo (on the GitLab side), drop this file at the root as
10+
# .gitlab-ci.yml. No edits needed — image name is derived from
11+
# $CI_REGISTRY_IMAGE so the same file works for every repo.
12+
#
13+
# 2. Set these CI/CD variables under Settings → CI/CD → Variables (group
14+
# level afrotomation, masked + hidden):
15+
# NEXT_PUBLIC_ANALYTICS_API_KEY
16+
# NEXT_PUBLIC_ANALYTICS_ENDPOINT
17+
# NEXT_PUBLIC_ANALYTICS_ENABLED = "true"
18+
# NEXT_PUBLIC_BETTER_AUTH_URL
19+
# NEXT_PUBLIC_BETTER_STACK_SOURCE_TOKEN
20+
# NEXT_PUBLIC_UMAMI_URL
21+
# NEXT_PUBLIC_UMAMI_WEBSITE_ID
22+
# ($CI_REGISTRY_USER / $CI_REGISTRY_PASSWORD / $CI_REGISTRY are
23+
# provided automatically by GitLab.)
24+
#
25+
# 3. Commit + push to the default branch — first build takes ~3-5 min,
26+
# image lands at registry.afrotomation.com/afrotomation/<repo>:latest.
27+
# ArgoCD image-updater on afrotomation-infra picks up the digest and
28+
# rolls the matching Deployment.
29+
30+
stages: [build]
31+
32+
build-image:
33+
stage: build
34+
image: docker:27-cli
35+
services:
36+
- name: docker:27-dind
37+
alias: docker
38+
variables:
39+
DOCKER_HOST: tcp://docker:2375/
40+
DOCKER_TLS_CERTDIR: ""
41+
DOCKER_BUILDKIT: "1"
42+
before_script:
43+
- apk add --no-cache curl bash
44+
# Wait for the DinD sidecar to finish booting (it deliberately delays
45+
# TCP bind by ~1s when listening insecure). buildx --bootstrap fails if
46+
# we hit the daemon before it's ready, so block until `docker info`
47+
# responds or we hit a 60s ceiling.
48+
- |
49+
for i in $(seq 1 60); do
50+
docker info > /dev/null 2>&1 && break
51+
sleep 1
52+
done
53+
docker info > /dev/null
54+
- echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin "$CI_REGISTRY"
55+
script:
56+
- |
57+
docker buildx create --use --name afrotomation-builder --driver docker-container --bootstrap
58+
docker buildx build \
59+
--platform linux/amd64 \
60+
--push \
61+
--build-arg "NEXT_PUBLIC_ANALYTICS_API_KEY=$NEXT_PUBLIC_ANALYTICS_API_KEY" \
62+
--build-arg "NEXT_PUBLIC_ANALYTICS_ENDPOINT=$NEXT_PUBLIC_ANALYTICS_ENDPOINT" \
63+
--build-arg "NEXT_PUBLIC_ANALYTICS_ENABLED=$NEXT_PUBLIC_ANALYTICS_ENABLED" \
64+
--build-arg "NEXT_PUBLIC_BETTER_AUTH_URL=$NEXT_PUBLIC_BETTER_AUTH_URL" \
65+
--build-arg "NEXT_PUBLIC_BETTER_STACK_SOURCE_TOKEN=$NEXT_PUBLIC_BETTER_STACK_SOURCE_TOKEN" \
66+
--build-arg "NEXT_PUBLIC_UMAMI_URL=$NEXT_PUBLIC_UMAMI_URL" \
67+
--build-arg "NEXT_PUBLIC_UMAMI_WEBSITE_ID=$NEXT_PUBLIC_UMAMI_WEBSITE_ID" \
68+
-t "$CI_REGISTRY_IMAGE:latest" \
69+
-t "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA" \
70+
-t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" \
71+
-f ./Dockerfile \
72+
.
73+
rules:
74+
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
75+
- if: $CI_COMMIT_TAG
76+
- if: $CI_PIPELINE_SOURCE == "web" # allow manual run
77+
tags:
78+
- k3s
79+
- docker

0 commit comments

Comments
 (0)