Commit b35e77c8 authored by Kevin Daudt's avatar Kevin Daudt 💻
Browse files

docker: define alpine version in a single location

Each Dockerfile hardcoded what Alpine Linux version to use, and to
upgrade to a newer Alpine version, each occurrence has to be adjusted.

There should not be a reason to combine different Alpine Linux versions,
so it makes sense to define the Alpine Linux version in a single
location.

Add a ALPINE-VERSION file where the version is determined and provide it
as build args for each Dockerfile.
parent 7f96ba88
ARG ALPINE_VERSION
ARG GITLAB_SHELL_VERSION
FROM alpinelinux/gitlab-shell:${GITLAB_SHELL_VERSION} as gitlab-shell
FROM ruby:2.7-alpine3.14
FROM ruby:2.7-alpine$ALPINE_VERSION
ARG GITLAB_VERSION
ENV GITLAB_VERSION=$GITLAB_VERSION
......
......@@ -16,6 +16,7 @@ tasks:
build:
desc: "build all images"
deps:
- .generate-env
- build-gitlab-shell
- build-gitaly
- build-gitlab
......@@ -74,11 +75,12 @@ tasks:
exit 1
fi
- printf '# GENERATED\n\n' >.env
- cat build-args.env .env.* >>.env
- find . \( -name build-args.env -o -name '.env.*' \) -exec cat {} + >>.env
- printf "ALPINE_VERSION=%s\n" "$(cat ALPINE-VERSION)" >>.env
- echo "Generated .env"
silent: true
deps: [ .build-args ]
sources: [ build-args.env, .env.* ]
sources: [ build-args.env, .env.* ALPINE-VERSION]
generates: [ .env ]
### GITLAB ###
......
......@@ -5,6 +5,7 @@ services:
build:
context: .
args:
- ALPINE_VERSION
- GITLAB_VERSION
- GITLAB_SHELL_VERSION
hostname: ${GITLAB_HOSTNAME:-gitlab}
......@@ -36,6 +37,7 @@ services:
build:
context: ./gitaly
args:
- ALPINE_VERSION
- GITALY_SERVER_VERSION
- GITLAB_SHELL_VERSION
depends_on:
......@@ -51,6 +53,7 @@ services:
build:
context: ./gitlab-shell
args:
- ALPINE_VERSION
- GITLAB_SHELL_VERSION
volumes:
- /srv/docker/gitlab/config/gitlab-shell:/etc/gitlab/gitlab-shell
......
ARG ALPINE_VERSION
ARG GITLAB_SHELL_VERSION
FROM curlimages/curl AS source
......@@ -13,7 +14,7 @@ RUN fetch-source
######################################################
FROM alpinelinux/golang:alpine3.14 AS build-gitaly
FROM alpinelinux/golang:$ALPINE_VERSION AS build-gitaly
COPY --from=source /tmp/src /tmp/src
COPY build/lib/ /usr/local/lib/
......@@ -40,7 +41,7 @@ RUN build-git
######################################################
FROM ruby:2.7-alpine3.14 AS build-gitaly-ruby
FROM ruby:2.7-alpine$ALPINE_VERSION AS build-gitaly-ruby
COPY --from=source /tmp/src /tmp/src
COPY build/lib/ /usr/local/lib/
......@@ -53,11 +54,11 @@ RUN build-gitaly-ruby
######################################################
# Hack because `copy --from` does not support variable expansion
FROM alpinelinux/gitlab-shell:${GITLAB_SHELL_VERSION} as gitlab-shell
FROM alpinelinux/gitlab-shell:$GITLAB_SHELL_VERSION as gitlab-shell
######################################################
FROM ruby:2.7-alpine3.14
FROM ruby:2.7-alpine$ALPINE_VERSION
COPY overlay /
COPY build/setup-image /usr/local/bin/
......
ARG ALPINE_VERSION
FROM curlimages/curl AS source
ARG GITLAB_SHELL_VERSION
......@@ -12,7 +13,7 @@ RUN fetch-source
######################################################
FROM alpinelinux/golang:alpine3.14 as builder
FROM alpinelinux/golang:$ALPINE_VERSION as builder
WORKDIR /tmp/src
USER root
......@@ -26,7 +27,7 @@ RUN build-gitlab-shell
######################################################
FROM alpine:3.14
FROM alpine:$ALPINE_VERSION
COPY overlay/ /
COPY --from=builder /home/git/gitlab-shell/ /home/git/gitlab-shell/
......
Supports Markdown
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