Update gitlab-ci configuration

This commit is contained in:
Deon George 2023-04-01 00:39:57 +11:00
parent 00953f7348
commit 66b5caede2
2 changed files with 29 additions and 35 deletions

View File

@ -1,45 +1,23 @@
image: docker:latest
stages: stages:
- test
- build - build
variables: variables:
DOCKER_HOST: tcp://docker:2375
VERSION: latest VERSION: latest
CACHETAG: build VERSIONARCH: ${VERSION}-${ARCH}
DOCKER_REGISTRY: registry.leenooks.net
DOCKER_IMAGE: ${DOCKER_REGISTRY}/${CI_PROJECT_PATH}
DOCKER_HOST: tcp://${DOCKER_REGISTRY}-leenooks-ci-docker:2375
image: docker:latest
services: services:
- ${DOCKER_REGISTRY}/leenooks/ci-docker:dind - docker:dind
before_script: before_script:
- docker info - if [ ! -d build-cache ]; then mkdir build-cache; fi
- docker version - sed -ie s'/https/http/' /etc/apk/repositories
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN ${DOCKER_REGISTRY} - HTTP_PROXY=http://proxy.dege.lan:3128 apk add git curl
- echo "CI_PROJECT_PATH ${CI_PROJECT_PATH} CI_COMMIT_TAG ${CI_COMMIT_TAG} CI_COMMIT_REF_NAME ${CI_COMMIT_REF_NAME}" - docker info && docker version
- echo "CI_REGISTRY ${CI_REGISTRY} CI_REGISTRY_IMAGE ${CI_REGISTRY_IMAGE} CI ${CI}" # env|sort
# 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
test: include:
stage: test - .gitlab-docker-x86_64.yml
script:
- cat /etc/hosts
- env|sort
- docker build -t ${DOCKER_IMAGE}:${VERSION} .
- docker images
only:
- debug
build:
stage: build
script:
- chmod 500 init
- docker pull ${DOCKER_IMAGE}:${CACHETAG}
- docker build --cache-from ${DOCKER_IMAGE}:${CACHETAG} -t ${DOCKER_IMAGE}:${VERSION} -t ${DOCKER_IMAGE}:${CACHETAG} .
- docker push ${DOCKER_IMAGE}:${VERSION}
- docker push ${DOCKER_IMAGE}:${CACHETAG}
tags:
- docker
only:
- master

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

@ -0,0 +1,16 @@
x86_64:build:
variables:
ARCH: x86_64
stage: build
script:
- if [ -f init ]; then chmod 500 init; fi
- ([ -z "$REFRESH" -a -f build-cache/${CI_COMMIT_REF_SLUG} ]) && docker load < build-cache/${CI_COMMIT_REF_SLUG} || true
- rm build-cache/* || 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} > build-cache/${CI_COMMIT_REF_SLUG}
tags:
- docker
- x86_64
only:
- master