diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fa870e8..7562d21 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,11 +1,10 @@ include: - local: 'gitlab-templates/base.yml' - - local: 'gitlab-templates/build-images.yml' + - local: 'gitlab-templates/build-and-push-image.yml' variables: - user: 'admin' - password: '${token}' - dockefile: 'alpine-with-ca.Dockerfile' - repository: 'artifact.onwalk.net/k8s' - image: 'apline' + username: 'admin' + password: '${repo-passwd}' + repository: 'artifact.onwalk.net' + image: 'k8s/alpine' tag: '3.13' diff --git a/base.yml b/base.yml new file mode 100644 index 0000000..e8e6383 --- /dev/null +++ b/base.yml @@ -0,0 +1,6 @@ +image: + name: artifact.onwalk.net/k8s/kaniko-executor:1.9.1-debug + entrypoint: [""] + +stages: + - build diff --git a/gitlab-templates/build-and-push-image.yml b/gitlab-templates/build-and-push-image.yml new file mode 100644 index 0000000..54ec350 --- /dev/null +++ b/gitlab-templates/build-and-push-image.yml @@ -0,0 +1,11 @@ +build-image-job: + stage: build + script: + - mkdir -p /kaniko/.docker + - echo "{\"auths\":{"https://${repository}":{\"auth\":\"$(printf "%s:%s" "${username}" "${password}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json + - cat /kaniko/.docker/config.json + - /kaniko/executor --context "${CI_PROJECT_DIR}" --dockerfile "Dockerfile" --destination "${repository}/${image}:${tag}" + tags: + - docker + rules: + - if: $CI_COMMIT_BRANCH == "main" diff --git a/gitlab-templates/build-images.yml b/gitlab-templates/build-images.yml deleted file mode 100644 index e15f6ab..0000000 --- a/gitlab-templates/build-images.yml +++ /dev/null @@ -1,11 +0,0 @@ -build-image-job: - stage: build - script: - - mkdir -p /kaniko/.docker - - echo "{\"auths\":{"${repository}":{\"auth\":\"$(printf "%s:%s" "${user}" "${password}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json - - /kaniko/executor --context "${CI_PROJECT_DIR}" --dockerfile "${CI_PROJECT_DIR}/${dockerfile}" --destination "${repository}/${image}:${tag}" - tags: - - shared - - shell - rules: - - if: $CI_COMMIT_BRANCH == "main"