Skip to content

Commit d326fd2

Browse files
committed
Move repo logic in the dockerfiles
in order to ease the build without build.sh Signed-off-by: Gaëtan Lehmann <[email protected]>
1 parent 1ec6108 commit d326fd2

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

Dockerfile-7.x

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
FROM centos:7.2.1511
1+
ARG CENTOS_VERSION=7.2.1511
2+
3+
FROM centos:${CENTOS_VERSION}
24

35
ARG CUSTOM_BUILDER_UID=""
46
ARG CUSTOM_BUILDER_GID=""
@@ -7,11 +9,15 @@ ARG CUSTOM_BUILDER_GID=""
79
RUN rm /etc/yum.repos.d/*
810

911
# Add only the specific CentOS 7.2 repositories, because that's what XS used for the majority of packages
10-
COPY files/tmp-CentOS-Vault.repo /etc/yum.repos.d/CentOS-Vault-7.2.repo
12+
ARG CENTOS_VERSION
13+
COPY files/CentOS-Vault.repo.in /etc/yum.repos.d/CentOS-Vault-7.2.repo
14+
RUN sed -e "s/@CENTOS_VERSION@/${CENTOS_VERSION}/g" -i /etc/yum.repos.d/CentOS-Vault-7.2.repo
1115

1216
# Add our repositories
1317
# Repository file depends on the target version of XCP-ng, and is pre-processed by build.sh
14-
COPY files/tmp-xcp-ng.repo /etc/yum.repos.d/xcp-ng.repo
18+
ARG XCP_NG_BRANCH=7.6
19+
COPY files/xcp-ng.repo.7.x.in /etc/yum.repos.d/xcp-ng.repo
20+
RUN sed -e "s/@XCP_NG_BRANCH@/${XCP_NG_BRANCH}/g" -i /etc/yum.repos.d/xcp-ng.repo
1521

1622
# Fix invalid rpmdb checksum error with overlayfs, see https://github.com/docker/docker/issues/10180
1723
RUN yum install -y yum-plugin-ovl

Dockerfile-8.x

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
FROM centos:7.5.1804
1+
ARG CENTOS_VERSION=7.5.1804
2+
3+
FROM centos:${CENTOS_VERSION}
24

35
ARG CUSTOM_BUILDER_UID=""
46
ARG CUSTOM_BUILDER_GID=""
@@ -7,11 +9,15 @@ ARG CUSTOM_BUILDER_GID=""
79
RUN rm /etc/yum.repos.d/*
810

911
# Add only the specific CentOS 7.5 repositories, because that's what XS used for the majority of packages
10-
COPY files/tmp-CentOS-Vault.repo /etc/yum.repos.d/CentOS-Vault-7.5.repo
12+
ARG CENTOS_VERSION
13+
COPY files/CentOS-Vault.repo.in /etc/yum.repos.d/CentOS-Vault-7.5.repo
14+
RUN sed -e "s/@CENTOS_VERSION@/${CENTOS_VERSION}/g" -i /etc/yum.repos.d/CentOS-Vault-7.5.repo
1115

1216
# Add our repositories
1317
# Repository file depends on the target version of XCP-ng, and is pre-processed by build.sh
14-
COPY files/tmp-xcp-ng.repo /etc/yum.repos.d/xcp-ng.repo
18+
ARG XCP_NG_BRANCH=8.3
19+
COPY files/xcp-ng.repo.8.x.in /etc/yum.repos.d/xcp-ng.repo
20+
RUN sed -e "s/@XCP_NG_BRANCH@/${XCP_NG_BRANCH}/g" -i /etc/yum.repos.d/xcp-ng.repo
1521

1622
# Install GPG key
1723
RUN curl -sSf https://xcp-ng.org/RPM-GPG-KEY-xcpng -o /etc/pki/rpm-gpg/RPM-GPG-KEY-xcpng

build.sh

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,11 @@ case "$1" in
7676
: ${PLATFORM:=linux/amd64/v2}
7777
;;
7878
8.*)
79-
REPO_FILE=files/xcp-ng.repo.8.x.in
8079
DOCKERFILE=Dockerfile-8.x
81-
CENTOS_VERSION=7.5.1804
8280
: ${PLATFORM:=linux/amd64}
8381
;;
8482
7.*)
85-
REPO_FILE=files/xcp-ng.repo.7.x.in
8683
DOCKERFILE=Dockerfile-7.x
87-
CENTOS_VERSION=7.2.1511
8884
: ${PLATFORM:=linux/amd64}
8985
;;
9086
*)
@@ -93,11 +89,6 @@ case "$1" in
9389
;;
9490
esac
9591

96-
if [ -n "$CENTOS_VERSION" ]; then
97-
sed -e "s/@XCP_NG_BRANCH@/${1}/g" "$REPO_FILE" > files/tmp-xcp-ng.repo
98-
sed -e "s/@CENTOS_VERSION@/${CENTOS_VERSION}/g" files/CentOS-Vault.repo.in > files/tmp-CentOS-Vault.repo
99-
fi
100-
10192
CUSTOM_UID="$(id -u)"
10293
CUSTOM_GID="$(id -g)"
10394

@@ -121,8 +112,6 @@ CUSTOM_ARGS+=( "--build-arg" "CUSTOM_BUILDER_GID=${CUSTOM_GID}" )
121112
--platform "$PLATFORM" \
122113
"${CUSTOM_ARGS[@]}" \
123114
-t xcp-ng/xcp-ng-build-env:${1} \
115+
--build-arg XCP_NG_BRANCH=${1} \
124116
--ulimit nofile=1024 \
125117
-f $DOCKERFILE .
126-
127-
rm -f files/tmp-xcp-ng.repo
128-
rm -f files/tmp-CentOS-Vault.repo

0 commit comments

Comments
 (0)