diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 88dd68168e817b2433f7ef5f03cfc001534fbc54..d79b8b717e11ecae46943e24b9c3e41924bcae3f 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}"