Split out .gitlab-ci to separate files, added arm64

This commit is contained in:
Deon George 2023-02-03 17:45:51 +11:00
parent 88503c81a2
commit c56a9e6a53
5 changed files with 124 additions and 93 deletions

View File

@ -1,116 +1,36 @@
image: docker:latest
stages: stages:
- build - build
- build-manifest - build-manifest
- build-test - build-test
- build-manifest-test - build-manifest-test
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- docker/
variables: variables:
BRANCH: alpine BRANCH: alpine
VERSION: 8.1-fpm-${BRANCH} VERSION: 8.1-fpm-${BRANCH}
DOCKER_HOST: tcp://docker:2375 DOCKER_HOST: tcp://docker:2375
VERSIONARCH: ${VERSION}-${ARCH} VERSIONARCH: ${VERSION}-${ARCH}
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- docker/
image: docker:latest
services: services:
- docker:dind - docker:dind
before_script: before_script:
- if [ ! -d docker ]; then mkdir docker; fi
- sed -ie s'/https/http/' /etc/apk/repositories - sed -ie s'/https/http/' /etc/apk/repositories
- HTTP_PROXY=http://proxy.dege.lan:3128 apk add git curl - HTTP_PROXY=http://proxy.dege.lan:3128 apk add git curl
- docker info - docker info
- docker version - docker version
- env|sort # env|sort
# docker login -u "$CI_DEPENDENCY_PROXY_USER" -p "$CI_DEPENDENCY_PROXY_PASSWORD" "$CI_SERVER_HOST" # docker login -u "$CI_DEPENDENCY_PROXY_USER" -p "$CI_DEPENDENCY_PROXY_PASSWORD" "$CI_SERVER_HOST"
- echo "$CI_JOB_TOKEN" | docker login -u "$CI_REGISTRY_USER" "$CI_REGISTRY" --password-stdin - echo "$CI_JOB_TOKEN" | docker login -u "$CI_REGISTRY_USER" "$CI_REGISTRY" --password-stdin
x86_64:build: include:
variables: - .gitlab-docker-x86_64.yml
ARCH: x86_64 - .gitlab-docker-armv7l.yml
stage: build - .gitlab-docker-arm64.yml
script: - .gitlab-docker-manifest.yml
- if [ -f init ]; then chmod 500 init; fi
- ([ -z "$REFRESH" -a -f docker/${CI_COMMIT_REF_SLUG} ]) && docker load < docker/${CI_COMMIT_REF_SLUG} || true
- docker build --build-arg HTTP_PROXY=http://proxy.dege.lan:3128 --cache-from ${CI_REGISTRY_IMAGE}:${VERSIONARCH} -t ${CI_REGISTRY_IMAGE}:${VERSIONARCH} .
- docker push ${CI_REGISTRY_IMAGE}:${VERSIONARCH}
- docker save ${CI_REGISTRY_IMAGE}:${VERSIONARCH} > docker/${CI_COMMIT_REF_SLUG}
# apk add curl && curl -LX POST --post301 -F token=${TRIGGER_TOKEN} -F ref=image ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/trigger/pipeline
# apk add curl && curl -LX POST --post301 -F token=${TRIGGER_TOKEN} -F ref=server ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/trigger/pipeline
tags:
- docker
- x86_64
only:
- alpine
x86_64:build-test:
variables:
ARCH: x86_64
stage: build-test
script:
- docker build --build-arg HTTP_PROXY=http://proxy.dege.lan:3128 --file Dockerfile.phptest -t ${CI_REGISTRY_IMAGE}:${VERSIONARCH}-test .
- docker push ${CI_REGISTRY_IMAGE}:${VERSIONARCH}-test
tags:
- docker
- x86_64
only:
- alpine
armv7l:build:
variables:
ARCH: armv7l
stage: build
script:
- if [ -f init ]; then chmod 500 init; fi
- ([ -z "$REFRESH" -a -f docker/${CI_COMMIT_REF_SLUG} ]) && docker load < docker/${CI_COMMIT_REF_SLUG} || true
- docker build --build-arg HTTP_PROXY=http://proxy.dege.lan:3128 --cache-from ${CI_REGISTRY_IMAGE}:${VERSIONARCH} -t ${CI_REGISTRY_IMAGE}:${VERSIONARCH} .
- docker push ${CI_REGISTRY_IMAGE}:${VERSIONARCH}
- docker save ${CI_REGISTRY_IMAGE}:${VERSIONARCH} > docker/${CI_COMMIT_REF_SLUG}
# apk add curl && curl -LX POST --post301 -F token=${TRIGGER_TOKEN} -F ref=image ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/trigger/pipeline
# apk add curl && curl -LX POST --post301 -F token=${TRIGGER_TOKEN} -F ref=server ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/trigger/pipeline
tags:
- docker
- armv7l
only:
- alpine
armv7l:build-test:
variables:
ARCH: armv7l
stage: build-test
script:
- docker build --build-arg HTTP_PROXY=http://proxy.dege.lan:3128 --file Dockerfile.phptest -t ${CI_REGISTRY_IMAGE}:${VERSIONARCH}-test .
- docker push ${CI_REGISTRY_IMAGE}:${VERSIONARCH}-test
tags:
- docker
- armv7l
only:
- alpine
x86_64:build-manifest:
stage: build-manifest
script:
- docker manifest create ${CI_REGISTRY_IMAGE}:${VERSION} ${CI_REGISTRY_IMAGE}:${VERSION}-armv7l ${CI_REGISTRY_IMAGE}:${VERSION}-x86_64
- docker manifest push --purge ${CI_REGISTRY_IMAGE}:${VERSION}
tags:
- docker
- x86_64
only:
- alpine
x86_64:build-manifest-test:
stage: build-manifest-test
script:
- docker manifest create ${CI_REGISTRY_IMAGE}:${VERSION}-test ${CI_REGISTRY_IMAGE}:${VERSION}-armv7l-test ${CI_REGISTRY_IMAGE}:${VERSION}-x86_64-test
- docker manifest push --purge ${CI_REGISTRY_IMAGE}:${VERSION}-test
tags:
- docker
- x86_64
only:
- alpine

30
.gitlab-docker-arm64.yml Normal file
View File

@ -0,0 +1,30 @@
arm64:build:
variables:
ARCH: arm64
stage: build
script:
- if [ -f init ]; then chmod 500 init; fi
- ([ -z "$REFRESH" -a -f docker/${CI_COMMIT_REF_SLUG} ]) && docker load < docker/${CI_COMMIT_REF_SLUG} || true
- docker build --build-arg HTTP_PROXY=http://proxy.dege.lan:3128 --cache-from ${CI_REGISTRY_IMAGE}:${VERSIONARCH} -t ${CI_REGISTRY_IMAGE}:${VERSIONARCH} .
- docker push ${CI_REGISTRY_IMAGE}:${VERSIONARCH}
- docker save ${CI_REGISTRY_IMAGE}:${VERSIONARCH} > docker/${CI_COMMIT_REF_SLUG}
# apk add curl && curl -LX POST --post301 -F token=${TRIGGER_TOKEN} -F ref=image ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/trigger/pipeline
# apk add curl && curl -LX POST --post301 -F token=${TRIGGER_TOKEN} -F ref=server ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/trigger/pipeline
tags:
- docker
- arm64
only:
- alpine
arm64:build-test:
variables:
ARCH: arm64
stage: build-test
script:
- docker build --build-arg HTTP_PROXY=http://proxy.dege.lan:3128 --file Dockerfile.phptest -t ${CI_REGISTRY_IMAGE}:${VERSIONARCH}-test .
- docker push ${CI_REGISTRY_IMAGE}:${VERSIONARCH}-test
tags:
- docker
- arm64
only:
- alpine

30
.gitlab-docker-armv7l.yml Normal file
View File

@ -0,0 +1,30 @@
armv7l:build:
variables:
ARCH: armv7l
stage: build
script:
- if [ -f init ]; then chmod 500 init; fi
- ([ -z "$REFRESH" -a -f docker/${CI_COMMIT_REF_SLUG} ]) && docker load < docker/${CI_COMMIT_REF_SLUG} || true
- docker build --build-arg HTTP_PROXY=http://proxy.dege.lan:3128 --cache-from ${CI_REGISTRY_IMAGE}:${VERSIONARCH} -t ${CI_REGISTRY_IMAGE}:${VERSIONARCH} .
- docker push ${CI_REGISTRY_IMAGE}:${VERSIONARCH}
- docker save ${CI_REGISTRY_IMAGE}:${VERSIONARCH} > docker/${CI_COMMIT_REF_SLUG}
# apk add curl && curl -LX POST --post301 -F token=${TRIGGER_TOKEN} -F ref=image ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/trigger/pipeline
# apk add curl && curl -LX POST --post301 -F token=${TRIGGER_TOKEN} -F ref=server ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/trigger/pipeline
tags:
- docker
- armv7l
only:
- alpine
armv7l:build-test:
variables:
ARCH: armv7l
stage: build-test
script:
- docker build --build-arg HTTP_PROXY=http://proxy.dege.lan:3128 --file Dockerfile.phptest -t ${CI_REGISTRY_IMAGE}:${VERSIONARCH}-test .
- docker push ${CI_REGISTRY_IMAGE}:${VERSIONARCH}-test
tags:
- docker
- armv7l
only:
- alpine

View File

@ -0,0 +1,21 @@
x86_64:build-manifest:
stage: build-manifest
script:
- docker manifest create ${CI_REGISTRY_IMAGE}:${VERSION} ${CI_REGISTRY_IMAGE}:${VERSION}-armv7l ${CI_REGISTRY_IMAGE}:${VERSION}-x86_64 ${CI_REGISTRY_IMAGE}:${VERSION}-arm64
- docker manifest push --purge ${CI_REGISTRY_IMAGE}:${VERSION}
tags:
- docker
- x86_64
only:
- alpine
x86_64:build-manifest-test:
stage: build-manifest-test
script:
- docker manifest create ${CI_REGISTRY_IMAGE}:${VERSION}-test ${CI_REGISTRY_IMAGE}:${VERSION}-armv7l-test ${CI_REGISTRY_IMAGE}:${VERSION}-x86_64-test ${CI_REGISTRY_IMAGE}:${VERSION}-arm64-test
- docker manifest push --purge ${CI_REGISTRY_IMAGE}:${VERSION}-test
tags:
- docker
- x86_64
only:
- alpine

30
.gitlab-docker-x86_64.yml Normal file
View File

@ -0,0 +1,30 @@
x86_64:build:
variables:
ARCH: x86_64
stage: build
script:
- if [ -f init ]; then chmod 500 init; fi
- ([ -z "$REFRESH" -a -f docker/${CI_COMMIT_REF_SLUG} ]) && docker load < docker/${CI_COMMIT_REF_SLUG} || true
- docker build --build-arg HTTP_PROXY=http://proxy.dege.lan:3128 --cache-from ${CI_REGISTRY_IMAGE}:${VERSIONARCH} -t ${CI_REGISTRY_IMAGE}:${VERSIONARCH} .
- docker push ${CI_REGISTRY_IMAGE}:${VERSIONARCH}
- docker save ${CI_REGISTRY_IMAGE}:${VERSIONARCH} > docker/${CI_COMMIT_REF_SLUG}
# apk add curl && curl -LX POST --post301 -F token=${TRIGGER_TOKEN} -F ref=image ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/trigger/pipeline
# apk add curl && curl -LX POST --post301 -F token=${TRIGGER_TOKEN} -F ref=server ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/trigger/pipeline
tags:
- docker
- x86_64
only:
- alpine
x86_64:build-test:
variables:
ARCH: x86_64
stage: build-test
script:
- docker build --build-arg HTTP_PROXY=http://proxy.dege.lan:3128 --file Dockerfile.phptest -t ${CI_REGISTRY_IMAGE}:${VERSIONARCH}-test .
- docker push ${CI_REGISTRY_IMAGE}:${VERSIONARCH}-test
tags:
- docker
- x86_64
only:
- alpine