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 <balasankar@gitlab.com>
This commit is contained in:
parent
f8c71c7a9c
commit
ca02e0c220
|
@ -10,6 +10,8 @@ ENV LANG=C.UTF-8
|
|||
COPY locale.gen /etc/locale.gen
|
||||
|
||||
# Install required packages
|
||||
# Note: libatomic1 is only required for arm64, but it is small enough to not
|
||||
# bother about the conditional inclusion logic
|
||||
RUN apt-get update -q \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
|
||||
busybox \
|
||||
|
@ -20,6 +22,7 @@ RUN apt-get update -q \
|
|||
wget \
|
||||
perl \
|
||||
libperl5.34 \
|
||||
libatomic1 \
|
||||
&& locale-gen \
|
||||
&& cp -a /usr/lib/locale/locale-archive /tmp/locale-archive \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get purge -yq locales \
|
||||
|
@ -43,6 +46,8 @@ RUN ln -fs /dev/null /run/motd.dynamic
|
|||
# Legacy code to be removed on 17.0. See: https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/7035
|
||||
ENV GITLAB_ALLOW_SHA1_RSA=false
|
||||
|
||||
ARG TARGETARCH
|
||||
|
||||
# Copy assets
|
||||
COPY RELEASE /
|
||||
COPY assets/ /assets/
|
||||
|
|
|
@ -10,9 +10,19 @@ source /RELEASE
|
|||
sed -i "/DOWNLOAD_URL/d;/CI_JOB_TOKEN/d;" /RELEASE
|
||||
|
||||
# Install GitLab
|
||||
if [[ "${TARGETARCH}" == "amd64" ]]; then
|
||||
export DOWNLOAD_URL=${DOWNLOAD_URL_amd64}
|
||||
elif [[ "${TARGETARCH}" == "arm64" ]]; then
|
||||
export DOWNLOAD_URL=${DOWNLOAD_URL_arm64}
|
||||
else
|
||||
echo "Unknown TARGETARCH: DOWNLOAD_URL not set"
|
||||
fi
|
||||
|
||||
DOWNLOAD_URL=${DOWNLOAD_URL} CI_JOB_TOKEN=${CI_JOB_TOKEN} /assets/download-package && dpkg -i /tmp/gitlab.deb
|
||||
rm -rf /tmp/gitlab.deb /var/lib/apt/lists/*
|
||||
|
||||
unset DOWNLOAD_URL_amd64
|
||||
unset DOWNLOAD_URL_arm64
|
||||
unset DOWNLOAD_URL
|
||||
unset CI_JOB_TOKEN
|
||||
|
||||
|
|
|
@ -315,6 +315,8 @@ Ubuntu-22.04-arm64-branch:
|
|||
- !reference [.default_rules, rules]
|
||||
- if: '$PIPELINE_TYPE =~ /_(NIGHTLY|BRANCH)_BUILD_PIPELINE$/'
|
||||
- if: '$PIPELINE_TYPE =~ /TRIGGERED_(CE|EE)_PIPELINE/'
|
||||
# TODO: When multi-arch images are built by default, make this an
|
||||
# automatic job
|
||||
when: manual
|
||||
allow_failure: true
|
||||
CentOS-7-branch:
|
||||
|
|
|
@ -13,15 +13,19 @@ module Build
|
|||
|
||||
def release_file_contents
|
||||
repo = Gitlab::Util.get_env('PACKAGECLOUD_REPO') # Target repository
|
||||
download_urls = {}.tap do |urls|
|
||||
urls[:amd64] = Build::Info::CI.package_download_url
|
||||
urls[:arm64] = Build::Info::CI.package_download_url(arch: 'arm64')
|
||||
end
|
||||
|
||||
download_url = Build::Info::CI.package_download_url
|
||||
raise "Unable to identify package download URL." unless download_url
|
||||
raise "Unable to identify package download URLs." if download_urls.empty?
|
||||
|
||||
contents = []
|
||||
contents << "PACKAGECLOUD_REPO=#{repo.chomp}\n" if repo && !repo.empty?
|
||||
contents << "RELEASE_PACKAGE=#{Build::Info::Package.name}\n"
|
||||
contents << "RELEASE_VERSION=#{Build::Info::Package.release_version}\n"
|
||||
contents << "DOWNLOAD_URL=#{download_url}\n"
|
||||
contents << "DOWNLOAD_URL_amd64=#{download_urls[:amd64]}\n"
|
||||
contents << "DOWNLOAD_URL_arm64=#{download_urls[:arm64]}\n"
|
||||
contents << "CI_JOB_TOKEN=#{Build::Info::CI.job_token}\n"
|
||||
contents.join
|
||||
end
|
||||
|
|
|
@ -109,7 +109,8 @@ RSpec.describe Build::Image do
|
|||
"PACKAGECLOUD_REPO=download-package",
|
||||
"RELEASE_PACKAGE=gitlab-ce",
|
||||
"RELEASE_VERSION=12.121.12-ce.0",
|
||||
"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",
|
||||
"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",
|
||||
"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",
|
||||
"CI_JOB_TOKEN=NOT-CI-JOB-TOKEN\n"
|
||||
].join("\n")
|
||||
end
|
||||
|
@ -130,7 +131,8 @@ RSpec.describe Build::Image do
|
|||
"PACKAGECLOUD_REPO=download-package",
|
||||
"RELEASE_PACKAGE=gitlab-ee",
|
||||
"RELEASE_VERSION=12.121.12-ee.0",
|
||||
"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",
|
||||
"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",
|
||||
"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",
|
||||
"CI_JOB_TOKEN=NOT-CI-JOB-TOKEN\n"
|
||||
].join("\n")
|
||||
end
|
||||
|
@ -159,7 +161,8 @@ RSpec.describe Build::Image do
|
|||
"PACKAGECLOUD_REPO=download-package",
|
||||
"RELEASE_PACKAGE=gitlab-ce",
|
||||
"RELEASE_VERSION=12.121.12-ce.0",
|
||||
"DOWNLOAD_URL=https://gitlab.com/api/v4/projects/20699/jobs/999999/artifacts/pkg/ubuntu-jammy/gitlab-ce_12.121.12-ce.0_amd64.deb",
|
||||
"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",
|
||||
"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",
|
||||
"CI_JOB_TOKEN=NOT-CI-JOB-TOKEN\n"
|
||||
].join("\n")
|
||||
end
|
||||
|
@ -180,7 +183,8 @@ RSpec.describe Build::Image do
|
|||
"PACKAGECLOUD_REPO=download-package",
|
||||
"RELEASE_PACKAGE=gitlab-ee",
|
||||
"RELEASE_VERSION=12.121.12-ee.0",
|
||||
"DOWNLOAD_URL=https://gitlab.com/api/v4/projects/20699/jobs/999999/artifacts/pkg/ubuntu-jammy/gitlab-ee_12.121.12-ee.0_amd64.deb",
|
||||
"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",
|
||||
"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",
|
||||
"CI_JOB_TOKEN=NOT-CI-JOB-TOKEN\n"
|
||||
].join("\n")
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue