Browse Source

split Containerfile in two

main
Nicolas Massé 2 weeks ago
parent
commit
d4133a3c63
  1. 34
      Containerfile
  2. 14
      Containerfile.base
  3. 21
      Containerfile.sync
  4. 4
      build.sh

34
Containerfile

@ -1,34 +0,0 @@
FROM registry.fedoraproject.org/fedora:latest
# Variables for URLs and versions
ARG CENTOS_VERSION=10
ARG EPEL_VERSION=10
ARG RSYNC_MIRROR=rsync://mirror.in2p3.fr
ARG CENTOS_PATH=/pub/linux/centos-stream/${CENTOS_VERSION}-stream/
ARG EPEL_PATH=/pub/epel/${EPEL_VERSION}/
# Install required tools
RUN dnf install -y rsync nginx && \
dnf clean all
# Copy exclusions file
COPY rsync-excludes.txt /etc/rsync-excludes.txt
# Build rsync options and sync repositories
RUN <<EOR
set -Eeuo pipefail
mkdir -p /var/www/centos/${CENTOS_VERSION}-stream
mkdir -p /var/www/epel/${EPEL_VERSION}
RSYNC_OPTS="-azH --progress --delete --exclude-from=/etc/rsync-excludes.txt"
rsync ${RSYNC_OPTS} ${RSYNC_MIRROR}${CENTOS_PATH} /var/www/centos/${CENTOS_VERSION}-stream/
rsync ${RSYNC_OPTS} ${RSYNC_MIRROR}${EPEL_PATH} /var/www/epel/${EPEL_VERSION}/
EOR
# Configure nginx
COPY nginx.conf /etc/nginx/nginx.conf
# Expose port 8080
EXPOSE 8080
# Start nginx in foreground mode
CMD ["nginx", "-g", "daemon off;"]

14
Containerfile.base

@ -0,0 +1,14 @@
FROM registry.fedoraproject.org/fedora:latest
# Install required tools
RUN dnf install -y rsync nginx && \
dnf clean all
# Configure nginx
COPY nginx.conf /etc/nginx/nginx.conf
# Expose port 8080
EXPOSE 8080
# Start nginx in foreground mode
CMD ["nginx", "-g", "daemon off;"]

21
Containerfile.sync

@ -0,0 +1,21 @@
FROM replaceme:latest
# Variables for URLs and versions
ARG CENTOS_VERSION=10 \
EPEL_VERSION=10 \
RSYNC_MIRROR=rsync://mirror.in2p3.fr \
CENTOS_PATH=/pub/linux/centos-stream \
EPEL_PATH=/pub/epel
# Copy exclusions file
COPY rsync-excludes.txt /etc/rsync-excludes.txt
# Build rsync options and sync repositories
RUN <<EOR
set -Eeuo pipefail
mkdir -p /var/www/centos/${CENTOS_VERSION}-stream
mkdir -p /var/www/epel/${EPEL_VERSION}
RSYNC_OPTS="-azH --progress --delete --exclude-from=/etc/rsync-excludes.txt"
rsync ${RSYNC_OPTS} ${RSYNC_MIRROR}${CENTOS_PATH}/${CENTOS_VERSION}-stream/ /var/www/centos/${CENTOS_VERSION}-stream/
rsync ${RSYNC_OPTS} ${RSYNC_MIRROR}${EPEL_PATH}/${EPEL_VERSION}/ /var/www/epel/${EPEL_VERSION}/
EOR

4
build.sh

@ -16,10 +16,14 @@ PODMAN_ARGS+=( -t "localhost/mirrors/centos-stream-${CENTOS_VERSION}:${TS}" )
# Run rsync on the previous dataset if available, to speed up transfer and save on storage.
if podman image inspect "localhost/mirrors/centos-stream-${CENTOS_VERSION}:latest" &>/dev/null; then
PODMAN_ARGS+=( --from "localhost/mirrors/centos-stream-${CENTOS_VERSION}:latest" )
PODMAN_ARGS+=( --file Containerfile.sync )
else
PODMAN_ARGS+=( --file Containerfile.base )
fi
# Build the image.
# Note: during the build, the repositories will be synced and the result will be stored in the image.
echo podman build "${PODMAN_ARGS[@]}" .
podman build "${PODMAN_ARGS[@]}" .
podman tag "localhost/mirrors/centos-stream-${CENTOS_VERSION}:${TS}" "localhost/mirrors/centos-stream-${CENTOS_VERSION}:latest"

Loading…
Cancel
Save