Commit 1ce4951c authored by Tomasz Maczukin's avatar Tomasz Maczukin

Refactor docker images build job

parent 3d75f1d6
......@@ -5,11 +5,12 @@ out
builds/
commands/helpers/archive.zip
executors/docker/bindata.go
dockerfiles/checksums
dockerfiles/alpine/gitlab-runner-linux-amd64
dockerfiles/alpine/checksums.sha256
dockerfiles/alpine/checksums
dockerfiles/build/gitlab-runner-helper
dockerfiles/ubuntu/gitlab-runner_amd64.deb
dockerfiles/ubuntu/checksums.sha256
dockerfiles/ubuntu/checksums
.idea/
.editorconfig
tests/ubuntu/.vagrant
......
......@@ -15,7 +15,7 @@ image: $CI_IMAGE
.docker: &docker
services:
- docker:dind
variables:
variables: &docker_variables
CI_IMAGE: registry.gitlab.com/gitlab-org/gitlab-runner/ci:1.8-1
DOCKER_DRIVER: overlay
DOCKER_HOST: tcp://docker:2375
......@@ -225,6 +225,14 @@ package-rpm: *packages
.release_docker_images: &release_docker_images
<<: *docker
stage: release
variables: &release_docker_images_variables
<<: *docker_variables
PUBLISH_IMAGES: "true"
PUSH_TO_DOCKER_HUB: "true"
DOCKER_MACHINE_VERSION: "0.13.0"
DOCKER_MACHINE_CHECKSUM: "8f5310eb9e04e71b44c80c0ccebd8a85be56266b4170b4a6ac6223f7b5640df9"
DUMB_INIT_VERSION: "1.0.2"
DUMB_INIT_CHECKSUM: "a8defac40aaca2ca0896c7c5adbc241af60c7c3df470c1a4c469a860bd805429"
script:
- source ci/touch_make_dependencies
- make release_docker_images
......@@ -270,6 +278,19 @@ development S3:
name: development/s3/${CI_COMMIT_REF_NAME}
url: https://gitlab-runner-downloads.s3.amazonaws.com/${CI_COMMIT_REF_NAME}/index.html
development docker images:
<<: *release_docker_images
variables:
<<: *release_docker_images_variables
PUBLISH_IMAGES: "false"
PUSH_TO_DOCKER_HUB: "false"
only:
- branches
except:
- master
tags:
- docker
bleeding edge S3:
<<: *release_s3
<<: *release_bleeding_edge
......
......@@ -20,7 +20,12 @@ _docker() {
build() {
echo -e "\033[1mBuilding image: \033[32m${1}\033[0m"
_docker build -t "${1}" "${2}"
_docker build \
--cache-from "${3}" \
--build-arg DOCKER_MACHINE_VERSION="${DOCKER_MACHINE_VERSION}" \
--build-arg DUMB_INIT_VERSION="${DUMB_INIT_VERSION}" \
-t "${1}" \
"${2}"
}
import() {
......@@ -41,6 +46,11 @@ tag_latest() {
tag "${@}"
}
pull() {
echo -e "\033[1mPulling image: \033[32m${1}\033[0m"
_docker pull "${1}"
}
push() {
echo -e "\033[1mPushing image: \033[32m${1}\033[0m"
_docker push "${1}"
......@@ -82,13 +92,20 @@ logout() {
_docker logout "${1}"
}
echo "${DOCKER_MACHINE_CHECKSUM} /usr/bin/docker-machine" >> dockerfiles/checksums
echo "${DUMB_INIT_CHECKSUM} /usr/bin/dumb-init" >> dockerfiles/checksums
cat dockerfiles/checksums
cp out/deb/gitlab-runner_amd64.deb dockerfiles/ubuntu/
cp dockerfiles/checksums.sha256 dockerfiles/ubuntu
cp dockerfiles/checksums dockerfiles/ubuntu
cp out/binaries/gitlab-runner-linux-amd64 dockerfiles/alpine
cp dockerfiles/checksums.sha256 dockerfiles/alpine
cp dockerfiles/checksums dockerfiles/alpine
pull gitlab/gitlab-runner:ubuntu
pull gitlab/gitlab-runner:alpine
build "gitlab/gitlab-runner:ubuntu-${ref_tag}" dockerfiles/ubuntu
build "gitlab/gitlab-runner:alpine-${ref_tag}" dockerfiles/alpine
build "gitlab/gitlab-runner:ubuntu-${ref_tag}" dockerfiles/ubuntu gitlab/gitlab-runner:ubuntu
build "gitlab/gitlab-runner:alpine-${ref_tag}" dockerfiles/alpine gitlab/gitlab-runner:alpine
tag "gitlab/gitlab-runner:ubuntu-${ref_tag}" "gitlab/gitlab-runner:${ref_tag}"
......@@ -96,6 +113,11 @@ tag_latest "gitlab/gitlab-runner:ubuntu-${ref_tag}" gitlab/gitlab-runner:ubuntu
tag_latest "gitlab/gitlab-runner:ubuntu-${ref_tag}" gitlab/gitlab-runner:latest
tag_latest "gitlab/gitlab-runner:alpine-${ref_tag}" gitlab/gitlab-runner:alpine
if [[ -z "${PUBLISH_IMAGES}" ]] || [[ "${PUBLISH_IMAGES}" != "true" ]]; then
echo "Skipping images pushing"
exit 0
fi
if [[ -n "${CI_REGISTRY}" ]] && [[ -n "${CI_REGISTRY_IMAGE}" ]]; then
tag "gitlab/gitlab-runner:ubuntu-${ref_tag}" "${CI_REGISTRY_IMAGE}:ubuntu-${ref_tag}"
tag "gitlab/gitlab-runner:alpine-${ref_tag}" "${CI_REGISTRY_IMAGE}:alpine-${ref_tag}"
......@@ -120,6 +142,11 @@ if [[ -n "${CI_REGISTRY}" ]] && [[ -n "${CI_REGISTRY_IMAGE}" ]]; then
fi
fi
if [[ -z "${PUSH_TO_DOCKER_HUB}" ]] || [[ "${PUSH_TO_DOCKER_HUB}" != "true" ]]; then
echo "Skipping push to Docker Hub"
exit 0
fi
if [[ -n "${DOCKER_HUB_USER}" ]] && [[ -n "${DOCKER_HUB_PASSWORD}" ]]; then
login "${DOCKER_HUB_USER}" "${DOCKER_HUB_PASSWORD}"
......
......@@ -14,7 +14,7 @@ ARG DOCKER_MACHINE_VERSION=0.13.0
ARG DUMB_INIT_VERSION=1.0.2
COPY gitlab-runner-linux-amd64 /usr/bin/gitlab-runner
COPY checksums.sha256 /tmp/
COPY checksums /tmp/
RUN chmod +x /usr/bin/gitlab-runner && \
ln -s /usr/bin/gitlab-runner /usr/bin/gitlab-ci-multi-runner && \
gitlab-runner --version && \
......@@ -26,7 +26,7 @@ RUN chmod +x /usr/bin/gitlab-runner && \
wget -q https://github.com/Yelp/dumb-init/releases/download/v${DUMB_INIT_VERSION}/dumb-init_${DUMB_INIT_VERSION}_amd64 -O /usr/bin/dumb-init && \
chmod +x /usr/bin/dumb-init && \
dumb-init --version && \
sha256sum -c -w /tmp/checksums.sha256
sha256sum -c -w /tmp/checksums
COPY entrypoint /
RUN chmod +x /entrypoint
......
3c0a1a03653dff205f27bb178773f3c294319435a2589cf3cb4456423f8cef08 /usr/bin/docker-machine
a8defac40aaca2ca0896c7c5adbc241af60c7c3df470c1a4c469a860bd805429 /usr/bin/dumb-init
......@@ -10,7 +10,7 @@ ARG DOCKER_MACHINE_VERSION=0.13.0
ARG DUMB_INIT_VERSION=1.0.2
COPY gitlab-runner_amd64.deb /tmp/
COPY checksums.sha256 /tmp/
COPY checksums /tmp/
RUN dpkg -i /tmp/gitlab-runner_amd64.deb; \
apt-get update && \
apt-get -f install -y && \
......@@ -26,7 +26,7 @@ RUN dpkg -i /tmp/gitlab-runner_amd64.deb; \
wget -q https://github.com/Yelp/dumb-init/releases/download/v${DUMB_INIT_VERSION}/dumb-init_${DUMB_INIT_VERSION}_amd64 -O /usr/bin/dumb-init && \
chmod +x /usr/bin/dumb-init && \
dumb-init --version && \
sha256sum --check --strict /tmp/checksums.sha256
sha256sum --check --strict /tmp/checksums
COPY entrypoint /
RUN chmod +x /entrypoint
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment