Select Git revision
.gitlab-ci.yml
Forked from
Startuplab / Courses / TJTS5901 Continuous Software Engineering / TJTS5901 K23 Template
Source project has a limited visibility.
.gitlab-ci.yml 2.54 KiB
## Use docker image as a base image.
image: docker:stable
services:
## Allow building docker images inside of docker. Notice that it's different
## from Docker-from-Docker. https://docs.gitlab.com/ee/ci/docker/using_docker_build.html
- name: docker:dind
entrypoint: ["env", "-u", "DOCKER_HOST"]
command: ["dockerd-entrypoint.sh"]
alias: docker
stages:
- build
- deploy
## Setup cache path for PIP packages.
## See: https://docs.gitlab.com/ee/ci/caching/#cache-python-dependencies
cache:
paths:
- .cache/pip
variables:
## Name for the generated image. Change this if you wish, but watch out
## for special characters!
APP_IMAGE_NAME: ${DOCKER_REGISTRY}/tjts5901
## (Optional) More verbose output from pipeline
#CI_DEBUG_TRACE: "true"
# When using dind service, we need to instruct docker to talk with
# the daemon started inside of the service. The daemon is available
# with a network connection instead of the default
# /var/run/docker.sock socket.
DOCKER_HOST: tcp://docker:2376
# shared volume for docker-in-docker
DOCKER_TLS_CERTDIR: "/certs"
DOCKER_CERT_PATH: "$DOCKER_TLS_CERTDIR/client"
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
## 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)
- docker info
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 $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:
stage: build
## Use build from previous stage as base image.
dependencies:
- build
image: $APP_IMAGE_NAME