Skip to content

Commit cd8216e

Browse files
committed
Gitlab CI experiment
1 parent 76002d3 commit cd8216e

File tree

6 files changed

+73
-0
lines changed

6 files changed

+73
-0
lines changed

.gitlab-ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include:
2+
- local: .gitlab_ci/base.yml

.gitlab_ci/_templates.yml

Whitespace-only changes.

.gitlab_ci/base.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
variables:
2+
# Use docker.io for Docker Hub if empty
3+
REGISTRY: registry.gitlab.com
4+
# IMAGE_NAME is defined as <account>/<repo> in GitLab CI/CD
5+
IMAGE_NAME: $CI_REGISTRY_IMAGE
6+
TEST_TAG: $REGISTRY/$CI_PROJECT_PATH:test
7+
8+
stages:
9+
- build
10+
- test
11+
- release
12+
13+
include:
14+
- local: /.gitlab_ci/build.yml
15+
- local: /.gitlab_ci/test.yml
16+
- local: /.gitlab_ci/release.yml

.gitlab_ci/build.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Build Docker image for test
2+
build-test:
3+
stage: build
4+
image: docker:24.0.2
5+
services:
6+
- docker:24.0.2-dind
7+
variables:
8+
DOCKER_BUILDKIT: 1
9+
before_script:
10+
- apk add --no-cache qemu bash
11+
script:
12+
- docker buildx create --use
13+
- docker buildx inspect --bootstrap
14+
- docker buildx build --load --target=dev --tag=$TEST_TAG --cache-to=type=local,dest=/tmp/.buildx-cache --cache-from=type=local,src=/tmp/.buildx-cache .
15+
artifacts:
16+
paths:
17+
- /tmp/.buildx-cache
18+
expire_in: 1h
19+
20+

.gitlab_ci/release.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Production Build with Multi-Arch
2+
release:
3+
stage: release
4+
image: docker:24.0.2
5+
only:
6+
- main
7+
services:
8+
- docker:24.0.2-dind
9+
variables:
10+
CI_REGISTRY_USER: "$CI_REGISTRY_USER"
11+
CI_REGISTRY_PASSWORD: "$CI_REGISTRY_PASSWORD"
12+
DOCKER_BUILDKIT: 1
13+
before_script:
14+
- apk add --no-cache qemu bash
15+
- docker buildx create --use
16+
- docker login $CI_REGISTRY -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD"
17+
script:
18+
- docker buildx inspect --bootstrap
19+
- |
20+
docker buildx build --push --target=http_app \
21+
--platform linux/amd64,linux/arm64 \
22+
--tag $CI_REGISTRY/$CI_PROJECT_PATH:latest \
23+
--tag $CI_REGISTRY/$CI_PROJECT_PATH:$(date +%Y%m%d%H%M%S) \
24+
--cache-to=type=registry,ref=$CI_REGISTRY/$CI_PROJECT_PATH/cache,mode=max \
25+
--cache-from=type=registry,ref=$CI_REGISTRY/$CI_PROJECT_PATH/cache .

.gitlab_ci/test.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Test Docker image
2+
test:
3+
stage: test
4+
image: docker:24.0.2
5+
services:
6+
- docker:24.0.2-dind
7+
before_script:
8+
- apk add --no-cache bash
9+
script:
10+
- docker run --rm $TEST_TAG make ci-test

0 commit comments

Comments
 (0)