From 424f765100b6adb75f86498c7942320f4312fb67 Mon Sep 17 00:00:00 2001 From: Teemu Autto <teemu@rautakuu.org> Date: Mon, 9 Jan 2023 02:21:50 +0000 Subject: [PATCH] Simplified build pipeline. --- .gitlab-ci.yml | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 88dd6816..d79b8b71 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,7 +20,7 @@ cache: variables: ## Name for the generated image. Change this if you wish, but watch out ## for special characters! - IMAGE_NAME: tjts5901 + APP_IMAGE_NAME: ${DOCKER_REGISTRY}/tjts5901 ## (Optional) More verbose output from pipeline #CI_DEBUG_TRACE: "true" @@ -39,11 +39,22 @@ variables: ## Build docker image build: + image: docker:stable stage: build + + before_script: + ## Make some checks that Docker credentials are configured. + - test -z "${DOCKER_REGISTRY}" && (echo "Missing required variable DOCKER_REGISTRY. See 'Pipeline setup.md'"; exit 1) + - test -z "${DOCKER_AUTH_CONFIG}" && (echo "Missing required variable DOCKER_AUTH_CONFIG. See 'Pipeline setup.md'"; exit 1) + script: ## Build a new image, pulling the latest base, and tag it. ## If --pull is ommited, base from local is used. - - docker build --pull -t $IMAGE_NAME . + - docker build --pull -t $APP_IMAGE_NAME . + ## Tag the build image for registry, and push it. + #- docker tag "${APP_IMAGE_NAME}" "${DOCKER_REGISTRY}:${APP_IMAGE_NAME}" + - docker push "${DOCKER_REGISTRY}:${APP_IMAGE_NAME}" + ## Build course documentation. You might not need this stage. pages: @@ -52,7 +63,7 @@ pages: ## Use build from previous stage as base image. dependencies: - build - image: $IMAGE_NAME + image: $APP_IMAGE_NAME script: ## Install `mkdocs` and generate HTML documentation. @@ -70,19 +81,3 @@ pages: ## Mark this stage as an "production" environment. environment: production -## Push image to container registry -push-image: - stage: deploy - dependencies: - - build - image: docker:stable - - before_script: - ## Make some checks that Docker credentials are configured. - - test -z "${DOCKER_REGISTRY}" && (echo "Missing required variable DOCKER_REGISTRY. See 'Pipeline setup.md'"; exit 1) - - test -z "${DOCKER_AUTH_CONFIG}" && (echo "Missing required variable DOCKER_AUTH_CONFIG. See 'Pipeline setup.md'"; exit 1) - - script: - ## Tag the build image for registry, and push it. - - docker tag "${IMAGE_NAME}" "${DOCKER_REGISTRY}:${IMAGE_NAME}" - - docker push "${DOCKER_REGISTRY}:${IMAGE_NAME}" -- GitLab