@@ -2,38 +2,32 @@ ARG CENTOS_VERSION=7.5.1804
22
33FROM centos :$ {CENTOS_VERSION }
44
5- ARG CUSTOM_BUILDER_UID = ""
6- ARG CUSTOM_BUILDER_GID = ""
7-
85# Remove all repositories
96RUN rm /etc /yum .repos .d /*
107
118# Add only the specific CentOS 7.5 repositories, because that's what XS used for the majority of packages
129ARG CENTOS_VERSION
1310COPY 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
11+ RUN sed - i - e "s/@CENTOS_VERSION@/${CENTOS_VERSION}/g" /etc /yum .repos .d /CentOS - Vault - 7.5 .repo
1512
1613# Add our repositories
1714# Repository file depends on the target version of XCP-ng, and is pre-processed by build.sh
1815ARG XCP_NG_BRANCH = 8.3
1916COPY 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
17+ RUN sed - i - e "s/@XCP_NG_BRANCH@/${XCP_NG_BRANCH}/g" /etc /yum .repos .d /xcp - ng .repo
2118
2219# Install GPG key
2320RUN curl - sSf https ://xcp-ng.org/RPM-GPG-KEY-xcpng -o /etc/pki/rpm-gpg/RPM-GPG-KEY-xcpng
2421
25- # Fix invalid rpmdb checksum error with overlayfs, see https://github.com/docker/docker/issues/10180
26- # (still needed ?)
27- RUN yum install - y yum - plugin - ovl
28-
29- # Use priorities so that packages from our repositories are preferred over those from CentOS repositories
30- RUN yum install - y yum - plugin - priorities
31-
3222# Update
33- RUN yum update - y
34-
35- # Common build requirements
36- RUN yum install - y \
23+ RUN yum update - y \
24+ # Fix invalid rpmdb checksum error with overlayfs, see https://github.com/docker/docker/issues/10180
25+ # (still needed ?)
26+ && yum install - y yum - plugin - ovl \
27+ # Use priorities so that packages from our repositories are preferred over those from CentOS repositories
28+ & & yum install - y yum - plugin - priorities \
29+ # Common build requirements
30+ & & yum install - y \
3731 gcc \
3832 gcc - c ++ \
3933 git \
@@ -44,37 +38,30 @@ RUN yum install -y \
4438 sudo \
4539 yum - utils \
4640 epel - release \
47- epel - rpm - macros
48-
49- # Niceties
50- RUN yum install - y \
41+ epel - rpm - macros \
42+ # Niceties
43+ && yum install - y \
5144 vim \
5245 wget \
53- which
54-
55- # clean package cache to avoid download errors
56- RUN yum clean all
46+ which \
47+ # clean package cache to avoid download errors
48+ & & yum clean all
5749
5850# OCaml in XS may be older than in CentOS
5951RUN sed - i "/gpgkey/a exclude=ocaml*" /etc /yum .repos .d /Cent * /etc /yum .repos .d /epel *
6052
61- # Set up the builder user
62- RUN bash - c ' \
63- OPTS=(); \
64- if [ -n "${CUSTOM_BUILDER_UID}" ]; then \
65- OPTS+=("-u" "${CUSTOM_BUILDER_UID}"); \
66- fi; \
67- if [ -n "${CUSTOM_BUILDER_GID}" ]; then \
68- OPTS+=("-g" "${CUSTOM_BUILDER_GID}"); \
69- if ! getent group "${CUSTOM_BUILDER_GID}" >/dev/null; then \
70- groupadd -g "${CUSTOM_BUILDER_GID}" builder; \
71- fi; \
72- fi; \
73- useradd "${OPTS[@]}" builder; \
74- ' \
53+ # create the builder user
54+ RUN groupadd - g 1000 builder \
55+ && useradd - u 1000 - g 1000 builder \
7556 && echo "builder:builder" | chpasswd \
7657 && echo "builder ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc /sudoers
7758
7859RUN mkdir - p /usr /local /bin
60+ RUN curl - fsSL "https://github.com/tianon/gosu/releases/download/1.17/gosu-amd64" - o /usr /local /bin /gosu \
61+ && chmod + x /usr /local /bin /gosu
7962COPY files /init - container .sh /usr /local /bin /init - container .sh
80- COPY files /rpmmacros /home /builder /.rpmmacros
63+ COPY files /entrypoint .sh /usr /local /bin /entrypoint .sh
64+ COPY -- chown = builder :builder files /rpmmacros /home /builder /.rpmmacros
65+
66+ ENTRYPOINT ["/usr/local/bin/entrypoint.sh" ]
67+ CMD ["bash" ]
0 commit comments