35 lines
1.2 KiB
YAML
35 lines
1.2 KiB
YAML
|
# To contribute improvements to CI/CD templates, please follow the Development guide at:
|
||
|
# https://docs.gitlab.com/ee/development/cicd/templates.html
|
||
|
# This specific template is located at:
|
||
|
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Docker.gitlab-ci.yml
|
||
|
|
||
|
# Build a Docker image with CI/CD and push to the GitLab registry.
|
||
|
# Docker-in-Docker documentation: https://docs.gitlab.com/ee/ci/docker/using_docker_build.html
|
||
|
#
|
||
|
# This template uses one generic job with conditional builds
|
||
|
# for the default branch and all other (MR) branches.
|
||
|
|
||
|
image: docker:latest
|
||
|
services:
|
||
|
- docker:dind
|
||
|
.build_template:
|
||
|
stage: build
|
||
|
variables:
|
||
|
IMAGE: "${NEXUS_URL}/docusaurus-${CI_ENVIRONMENT_NAME}:latest"
|
||
|
before_script:
|
||
|
- docker --version
|
||
|
- echo "${IMAGE}"
|
||
|
- docker login "${NEXUS_URL}" --username "${NEXUS_USER}" --password "${NEXUS_PASSWORD}"
|
||
|
- echo $(docker pull "${IMAGE}")
|
||
|
script:
|
||
|
- docker build . -t "docusaurus-${CI_ENVIRONMENT_NAME}:latest"
|
||
|
- docker tag "docusaurus-${CI_ENVIRONMENT_NAME}:latest" "${IMAGE}"
|
||
|
- docker push "${IMAGE}"
|
||
|
|
||
|
build_preproduction:
|
||
|
extends: .build_template
|
||
|
environment:
|
||
|
name: preproduction
|
||
|
only:
|
||
|
- preproduction
|