11# Base image for Debian-based distributions (e.g. `debian:10` or `ubuntu:18.04`)
22ARG DEBIAN_BASE=ubuntu:18.04
33
4+ # Base image for CentOS-based distributions (e.g. `centos:7` or `centos:8`)
5+ ARG CENTOS_BASE=centos:7
6+
47# Intermediate image to use as Opam-enabled distribution (e.g. `opam-alpine` or
58# `opam-debian-based`).
6- ARG OPAM_BASE=opam-centos-7
9+ ARG OPAM_BASE=opam-centos-based
710
811FROM debian:12-slim AS downloader
912
@@ -78,13 +81,15 @@ RUN opam init --yes --compiler "$OCAML_VERSION" --disable-sandboxing
7881RUN mkdir "/home/$user/workdir"
7982WORKDIR "/home/$user/workdir"
8083
81- FROM centos:7 AS opam-centos-7
84+ FROM $CENTOS_BASE AS opam-centos-based
8285
8386# Fix repository URLs (because CentOS 7 is deprecated)
84- RUN (. /etc/os-release && [ "$ID" = "centos" ] && [ "$VERSION_ID" = "7" ]) \
85- && sed -i 's/mirror.centos.org/vault.centos.org/g' /etc/yum.repos.d/*.repo \
86- && sed -i 's/^#.*baseurl=http/baseurl=http/g' /etc/yum.repos.d/*.repo \
87- && sed -i 's/^mirrorlist=http/#mirrorlist=http/g' /etc/yum.repos.d/*.repo
87+ RUN . /etc/os-release \
88+ && if [ "$ID" = "centos" ] && ([ "$VERSION_ID" = "7" ] || [ "$VERSION_ID" = "8" ]); then \
89+ sed -i 's/mirror.centos.org/vault.centos.org/g' /etc/yum.repos.d/*.repo; \
90+ sed -i 's/^#.*baseurl=http/baseurl=http/g' /etc/yum.repos.d/*.repo; \
91+ sed -i 's/^mirrorlist=http/#mirrorlist=http/g' /etc/yum.repos.d/*.repo; \
92+ fi
8893
8994# Add user with password-less sudo
9095ARG user=main
@@ -101,10 +106,12 @@ USER "$user"
101106USER root
102107RUN yum install -y \
103108 bzip2 \
109+ diffutils \
104110 gcc \
105111 git \
106112 make \
107113 patch \
114+ rsync \
108115 unzip \
109116 wget \
110117 && yum clean all \
0 commit comments