Compare commits
29 Commits
bug-cannot
...
push_alrea
Author | SHA1 | Date | |
---|---|---|---|
059a24d638 | |||
45071f0faa | |||
0791f1145b | |||
51c58d6407 | |||
0bf519a351 | |||
1eb8e6fb5c | |||
c4b8236446 | |||
162c6fb01a | |||
11c6b51be6 | |||
17712bf3ae | |||
7a438a29ed | |||
b0cd962ce9 | |||
92462d8986 | |||
8d1a4408ce | |||
179688d8c0 | |||
cb674587f6 | |||
dc0ec87635 | |||
4c86b4fd8a | |||
d48d8e217d | |||
0ac1d8ad65 | |||
c46fcb14f7 | |||
3ec7aace8a | |||
07b65bee1f | |||
1589518259 | |||
9fe7931202 | |||
8daf43276b | |||
2173a6a36e | |||
f9c992dcb2 | |||
fd9eae23eb |
4
.dockerignore
Normal file
4
.dockerignore
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
# CI cache folder storing docker images
|
||||||
|
ci-exports/
|
||||||
|
|
||||||
|
.gitlab-ci.yml
|
95
.gitlab-ci.yml
Normal file
95
.gitlab-ci.yml
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
image: docker:19.03.12
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- docker_test
|
||||||
|
- docker_push
|
||||||
|
|
||||||
|
variables:
|
||||||
|
# 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 19.03 does this automatically
|
||||||
|
# by setting the DOCKER_HOST in
|
||||||
|
# https://github.com/docker-library/docker/blob/d45051476babc297257df490d22cbd806f1b11e4/19.03/docker-entrypoint.sh#L23-L29
|
||||||
|
#
|
||||||
|
# The 'docker' hostname is the alias of the service container as described at
|
||||||
|
# https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#accessing-the-services.
|
||||||
|
#
|
||||||
|
# Specify to Docker where to create the certificates, Docker will
|
||||||
|
# create them automatically on boot, and will create
|
||||||
|
# `/certs/client` that will be shared between the service and job
|
||||||
|
# container, thanks to volume mount from config.toml
|
||||||
|
DOCKER_TLS_CERTDIR: "/certs"
|
||||||
|
# Use TLS https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#tls-enabled
|
||||||
|
DOCKER_HOST: tcp://docker:2376
|
||||||
|
|
||||||
|
.docker_cache:
|
||||||
|
cache:
|
||||||
|
key: "$CI_COMMIT_REF_SLUG"
|
||||||
|
paths:
|
||||||
|
- ci-exports/*.tar
|
||||||
|
|
||||||
|
services:
|
||||||
|
- docker:19.03.12-dind
|
||||||
|
|
||||||
|
|
||||||
|
# Make sure we can build a docker image
|
||||||
|
# It's pushed to the pipeline-local registry which acts as a cache
|
||||||
|
build_docker:
|
||||||
|
extends:
|
||||||
|
- .docker_cache
|
||||||
|
stage: docker_test
|
||||||
|
script:
|
||||||
|
# Try to load latest branch image from local tar or from registry
|
||||||
|
- docker load ci-exports/$CI_COMMIT_REF_SLUG.tar || docker pull $CI_REGISTRY_IMAGE:latest || true
|
||||||
|
- docker build --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:latest .
|
||||||
|
- mkdir -p ci-exports/
|
||||||
|
- docker save $CI_REGISTRY_IMAGE:latest > ci-exports/$CI_COMMIT_REF_SLUG.tar
|
||||||
|
|
||||||
|
# Publishes the configured CI registry (by default that's gitlab's registry)
|
||||||
|
push_ci_registry:
|
||||||
|
extends:
|
||||||
|
- .docker_cache
|
||||||
|
stage: docker_push
|
||||||
|
cache:
|
||||||
|
policy: pull
|
||||||
|
before_script:
|
||||||
|
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
||||||
|
script:
|
||||||
|
- cat ci-exports/$CI_COMMIT_REF_SLUG.tar | docker load
|
||||||
|
- docker tag $CI_REGISTRY_IMAGE:latest $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
|
||||||
|
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
|
||||||
|
- docker push $CI_REGISTRY_IMAGE:latest
|
||||||
|
only:
|
||||||
|
refs:
|
||||||
|
- master
|
||||||
|
variables:
|
||||||
|
- $CI_REGISTRY_USER
|
||||||
|
- $CI_REGISTRY_PASSWORD
|
||||||
|
- $CI_REGISTRY
|
||||||
|
- $CI_REGISTRY_IMAGE
|
||||||
|
|
||||||
|
# Publishes the cached image to docker
|
||||||
|
push_dockerhub_registry:
|
||||||
|
extends:
|
||||||
|
- .docker_cache
|
||||||
|
stage: docker_push
|
||||||
|
cache:
|
||||||
|
policy: pull
|
||||||
|
before_script:
|
||||||
|
- docker login -u $DOCKERHUB_REGISTRY_USER -p $DOCKERHUB_REGISTRY_PASSWORD $DOCKERHUB_REGISTRY
|
||||||
|
script:
|
||||||
|
- cat ci-exports/$CI_COMMIT_REF_SLUG.tar | docker load
|
||||||
|
- docker tag $CI_REGISTRY_IMAGE:latest $DOCKERHUB_REGISTRY_IMAGE:$CI_COMMIT_TAG
|
||||||
|
- docker tag $CI_REGISTRY_IMAGE:latest $DOCKERHUB_REGISTRY_IMAGE:latest
|
||||||
|
- docker push $DOCKERHUB_REGISTRY_IMAGE:$CI_COMMIT_TAG
|
||||||
|
- docker push $DOCKERHUB_REGISTRY_IMAGE:latest
|
||||||
|
only:
|
||||||
|
refs:
|
||||||
|
# - master
|
||||||
|
- tags
|
||||||
|
variables:
|
||||||
|
- $DOCKERHUB_REGISTRY_USER
|
||||||
|
- $DOCKERHUB_REGISTRY_PASSWORD
|
||||||
|
- $DOCKERHUB_REGISTRY
|
||||||
|
- $DOCKERHUB_REGISTRY_IMAGE
|
Reference in New Issue
Block a user