Skip to content

Commit ca02e0c

Browse files
committed
Enable building arm64 images
Modify the Dockerfile and library code around Docker image builds to support building multiarch images. The Dockerfile will download the package for the correct architecture based on TARGETARCH variable. Closes: https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/8470 Signed-off-by: Balasankar 'Balu' C <[email protected]>
1 parent f8c71c7 commit ca02e0c

File tree

5 files changed

+32
-7
lines changed

5 files changed

+32
-7
lines changed

docker/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ ENV LANG=C.UTF-8
1010
COPY locale.gen /etc/locale.gen
1111

1212
# Install required packages
13+
# Note: libatomic1 is only required for arm64, but it is small enough to not
14+
# bother about the conditional inclusion logic
1315
RUN apt-get update -q \
1416
&& DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
1517
busybox \
@@ -20,6 +22,7 @@ RUN apt-get update -q \
2022
wget \
2123
perl \
2224
libperl5.34 \
25+
libatomic1 \
2326
&& locale-gen \
2427
&& cp -a /usr/lib/locale/locale-archive /tmp/locale-archive \
2528
&& DEBIAN_FRONTEND=noninteractive apt-get purge -yq locales \
@@ -43,6 +46,8 @@ RUN ln -fs /dev/null /run/motd.dynamic
4346
# Legacy code to be removed on 17.0. See: https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/7035
4447
ENV GITLAB_ALLOW_SHA1_RSA=false
4548

49+
ARG TARGETARCH
50+
4651
# Copy assets
4752
COPY RELEASE /
4853
COPY assets/ /assets/

docker/assets/setup

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,19 @@ source /RELEASE
1010
sed -i "/DOWNLOAD_URL/d;/CI_JOB_TOKEN/d;" /RELEASE
1111

1212
# Install GitLab
13+
if [[ "${TARGETARCH}" == "amd64" ]]; then
14+
export DOWNLOAD_URL=${DOWNLOAD_URL_amd64}
15+
elif [[ "${TARGETARCH}" == "arm64" ]]; then
16+
export DOWNLOAD_URL=${DOWNLOAD_URL_arm64}
17+
else
18+
echo "Unknown TARGETARCH: DOWNLOAD_URL not set"
19+
fi
20+
1321
DOWNLOAD_URL=${DOWNLOAD_URL} CI_JOB_TOKEN=${CI_JOB_TOKEN} /assets/download-package && dpkg -i /tmp/gitlab.deb
1422
rm -rf /tmp/gitlab.deb /var/lib/apt/lists/*
1523

24+
unset DOWNLOAD_URL_amd64
25+
unset DOWNLOAD_URL_arm64
1626
unset DOWNLOAD_URL
1727
unset CI_JOB_TOKEN
1828

gitlab-ci-config/dev-gitlab-org.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,8 @@ Ubuntu-22.04-arm64-branch:
315315
- !reference [.default_rules, rules]
316316
- if: '$PIPELINE_TYPE =~ /_(NIGHTLY|BRANCH)_BUILD_PIPELINE$/'
317317
- if: '$PIPELINE_TYPE =~ /TRIGGERED_(CE|EE)_PIPELINE/'
318+
# TODO: When multi-arch images are built by default, make this an
319+
# automatic job
318320
when: manual
319321
allow_failure: true
320322
CentOS-7-branch:

lib/gitlab/build/info/docker.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,19 @@ def tag
1313

1414
def release_file_contents
1515
repo = Gitlab::Util.get_env('PACKAGECLOUD_REPO') # Target repository
16+
download_urls = {}.tap do |urls|
17+
urls[:amd64] = Build::Info::CI.package_download_url
18+
urls[:arm64] = Build::Info::CI.package_download_url(arch: 'arm64')
19+
end
1620

17-
download_url = Build::Info::CI.package_download_url
18-
raise "Unable to identify package download URL." unless download_url
21+
raise "Unable to identify package download URLs." if download_urls.empty?
1922

2023
contents = []
2124
contents << "PACKAGECLOUD_REPO=#{repo.chomp}\n" if repo && !repo.empty?
2225
contents << "RELEASE_PACKAGE=#{Build::Info::Package.name}\n"
2326
contents << "RELEASE_VERSION=#{Build::Info::Package.release_version}\n"
24-
contents << "DOWNLOAD_URL=#{download_url}\n"
27+
contents << "DOWNLOAD_URL_amd64=#{download_urls[:amd64]}\n"
28+
contents << "DOWNLOAD_URL_arm64=#{download_urls[:arm64]}\n"
2529
contents << "CI_JOB_TOKEN=#{Build::Info::CI.job_token}\n"
2630
contents.join
2731
end

spec/lib/gitlab/build/image_spec.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ def self.dockerhub_image_name
109109
"PACKAGECLOUD_REPO=download-package",
110110
"RELEASE_PACKAGE=gitlab-ce",
111111
"RELEASE_VERSION=12.121.12-ce.0",
112-
"DOWNLOAD_URL=https://dev.gitlab.org/api/v4/projects/283/jobs/999999/artifacts/pkg/ubuntu-jammy/gitlab-ce_12.121.12-ce.0_amd64.deb",
112+
"DOWNLOAD_URL_amd64=https://dev.gitlab.org/api/v4/projects/283/jobs/999999/artifacts/pkg/ubuntu-jammy/gitlab-ce_12.121.12-ce.0_amd64.deb",
113+
"DOWNLOAD_URL_arm64=https://dev.gitlab.org/api/v4/projects/283/jobs/999999/artifacts/pkg/ubuntu-jammy_aarch64/gitlab-ce_12.121.12-ce.0_arm64.deb",
113114
"CI_JOB_TOKEN=NOT-CI-JOB-TOKEN\n"
114115
].join("\n")
115116
end
@@ -130,7 +131,8 @@ def self.dockerhub_image_name
130131
"PACKAGECLOUD_REPO=download-package",
131132
"RELEASE_PACKAGE=gitlab-ee",
132133
"RELEASE_VERSION=12.121.12-ee.0",
133-
"DOWNLOAD_URL=https://dev.gitlab.org/api/v4/projects/283/jobs/999999/artifacts/pkg/ubuntu-jammy/gitlab-ee_12.121.12-ee.0_amd64.deb",
134+
"DOWNLOAD_URL_amd64=https://dev.gitlab.org/api/v4/projects/283/jobs/999999/artifacts/pkg/ubuntu-jammy/gitlab-ee_12.121.12-ee.0_amd64.deb",
135+
"DOWNLOAD_URL_arm64=https://dev.gitlab.org/api/v4/projects/283/jobs/999999/artifacts/pkg/ubuntu-jammy_aarch64/gitlab-ee_12.121.12-ee.0_arm64.deb",
134136
"CI_JOB_TOKEN=NOT-CI-JOB-TOKEN\n"
135137
].join("\n")
136138
end
@@ -159,7 +161,8 @@ def self.dockerhub_image_name
159161
"PACKAGECLOUD_REPO=download-package",
160162
"RELEASE_PACKAGE=gitlab-ce",
161163
"RELEASE_VERSION=12.121.12-ce.0",
162-
"DOWNLOAD_URL=https://gitlab.com/api/v4/projects/20699/jobs/999999/artifacts/pkg/ubuntu-jammy/gitlab-ce_12.121.12-ce.0_amd64.deb",
164+
"DOWNLOAD_URL_amd64=https://gitlab.com/api/v4/projects/20699/jobs/999999/artifacts/pkg/ubuntu-jammy/gitlab-ce_12.121.12-ce.0_amd64.deb",
165+
"DOWNLOAD_URL_arm64=https://gitlab.com/api/v4/projects/20699/jobs/999999/artifacts/pkg/ubuntu-jammy_aarch64/gitlab-ce_12.121.12-ce.0_arm64.deb",
163166
"CI_JOB_TOKEN=NOT-CI-JOB-TOKEN\n"
164167
].join("\n")
165168
end
@@ -180,7 +183,8 @@ def self.dockerhub_image_name
180183
"PACKAGECLOUD_REPO=download-package",
181184
"RELEASE_PACKAGE=gitlab-ee",
182185
"RELEASE_VERSION=12.121.12-ee.0",
183-
"DOWNLOAD_URL=https://gitlab.com/api/v4/projects/20699/jobs/999999/artifacts/pkg/ubuntu-jammy/gitlab-ee_12.121.12-ee.0_amd64.deb",
186+
"DOWNLOAD_URL_amd64=https://gitlab.com/api/v4/projects/20699/jobs/999999/artifacts/pkg/ubuntu-jammy/gitlab-ee_12.121.12-ee.0_amd64.deb",
187+
"DOWNLOAD_URL_arm64=https://gitlab.com/api/v4/projects/20699/jobs/999999/artifacts/pkg/ubuntu-jammy_aarch64/gitlab-ee_12.121.12-ee.0_arm64.deb",
184188
"CI_JOB_TOKEN=NOT-CI-JOB-TOKEN\n"
185189
].join("\n")
186190
end

0 commit comments

Comments
 (0)