aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2020-07-13 12:26:13 +0200
committerGerd Hoffmann <kraxel@redhat.com>2020-07-13 12:26:13 +0200
commitfdf0b23d27a02247e1806789dd46634421227682 (patch)
tree0fc796d6d7448665ae08f9e2d4d89ff64bdc49c4
parent42df4261fcefb4b475c09235043ebb48a3154982 (diff)
downloads2i-jekyll-fdf0b23d27a02247e1806789dd46634421227682.tar.gz
switch to common podman ci config
-rw-r--r--.gitlab-ci.yml32
1 files changed, 1 insertions, 31 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 61c74f9..44a501e 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,34 +1,16 @@
-# This is a GitLab CI configuration to build the project as a docker image
-# The file is generic enough to be dropped in a project containing a working Dockerfile
-# Author: Florent CHAUVEAU <florent.chauveau@gmail.com>
-# Mentioned here: https://blog.callr.tech/building-docker-images-with-gitlab-ci-best-practices/
-
-# do not use "latest" here, if you want this to work in the future
-#image: docker:18
image: registry.gitlab.com/kraxel/podman-docker-builder:latest
stages:
- build
- push
-# Use this if your GitLab runner does not use socket binding
-#services:
-# - docker:dind
-
before_script:
- # docker login asks for the password to be passed through stdin for security
- # we use $CI_JOB_TOKEN here which is a special token provided by GitLab
- - echo -n $CI_JOB_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY
+ - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
Build:
stage: build
script:
- # fetches the latest image (not failing if image is not found)
- docker pull $CI_REGISTRY_IMAGE:latest || true
- # builds the project, passing proxy variables, and vcs vars for LABEL
- # notice the cache-from, which is going to use the image we just pulled locally
- # the built image is tagged locally with the commit SHA, and then pushed to
- # the GitLab registry
- >
docker build
--pull
@@ -39,34 +21,22 @@ Build:
.
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
-# Here, the goal is to tag the "master" branch as "latest"
Push latest:
variables:
- # We are just playing with Docker here.
- # We do not need GitLab to clone the source code.
GIT_STRATEGY: none
stage: push
only:
- # Only "master" should be tagged "latest"
- master
script:
- # Because we have no guarantee that this job will be picked up by the same runner
- # that built the image in the previous step, we pull it again locally
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
- # Then we tag it "latest"
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:latest
- # Annnd we push it.
- docker push $CI_REGISTRY_IMAGE:latest
-# Finally, the goal here is to Docker tag any Git tag
-# GitLab will start a new pipeline everytime a Git tag is created, which is pretty awesome
Push tag:
variables:
- # Again, we do not need the source code here. Just playing with Docker.
GIT_STRATEGY: none
stage: push
only:
- # We want this job to be run on tags only.
- tags
script:
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA