2022-01-30 04:07:09 +01:00
ARG S6_OVERLAY_VERSION = "3.0.0.2"
2022-01-30 04:03:56 +01:00
ARG S6_OVERLAY_RELEASE = "https://github.com/just-containers/s6-overlay/releases/download/"
2022-09-14 00:56:16 +02:00
ARG S6_OVERLAY_PAK_EXT = ".tar.xz"
2022-01-14 21:54:59 +01:00
2022-01-30 04:03:56 +01:00
# First stage - Download s6-overlay noarch base and unpack it
FROM scratch AS downloader-s6-base
ARG S6_OVERLAY_VERSION
ARG S6_OVERLAY_RELEASE
2022-09-14 00:56:16 +02:00
ARG S6_OVERLAY_PAK_EXT
ADD " ${ S6_OVERLAY_RELEASE } /v ${ S6_OVERLAY_VERSION } /s6-overlay-noarch ${ S6_OVERLAY_PAK_EXT } " /s6overlay-base.tar.xz
2022-01-14 21:54:59 +01:00
2022-01-30 04:03:56 +01:00
# Second stage - Download s6-overlay platform-dependent binaries and unpack
2022-09-13 23:06:31 +02:00
FROM --platform=${TARGETPLATFORM} alpine:3.16.2 AS downloader-s6-bin
2022-01-14 21:54:59 +01:00
ARG TARGETPLATFORM
2022-01-30 04:03:56 +01:00
ARG S6_OVERLAY_VERSION
ARG S6_OVERLAY_RELEASE
2022-09-14 00:56:16 +02:00
ARG S6_OVERLAY_PAK_EXT
ARG S6_OVERLAY_RELEASE_URL = " ${ S6_OVERLAY_RELEASE } /v ${ S6_OVERLAY_VERSION } /s6-overlay- ${ TARGETPLATFORM } ${ S6_OVERLAY_PAK_EXT } "
2022-01-14 21:54:59 +01:00
2022-01-30 04:15:55 +01:00
RUN apk add --no-cache wget \
&& wget -O /s6overlay-bin.tar.xz " $( echo ${ S6_OVERLAY_RELEASE_URL } | sed 's/linux\///g' | sed 's/amd64/x86_64/g' | sed 's/arm64/aarch64/g' | sed 's/arm\/v7/armhf/g' ) "
2022-01-30 04:03:56 +01:00
# Third stage - Build rootfs from s6 parts
2022-09-13 23:06:31 +02:00
FROM alpine:3.16.2 AS rootfs-builder
2022-01-30 04:03:56 +01:00
COPY --from= downloader-s6-base [ "/s6overlay-base.tar.xz" , "/s6overlay-base.tar.xz" ]
COPY --from= downloader-s6-bin [ "/s6overlay-bin.tar.xz" , "/s6overlay-bin.tar.xz" ]
WORKDIR "/rootfs-build/"
2022-01-14 21:54:59 +01:00
2022-01-30 04:03:56 +01:00
RUN apk add --no-cache tar xz \
&& tar -Jxpf /s6overlay-base.tar.xz -C /rootfs-build \
&& tar -Jxpf /s6overlay-bin.tar.xz -C /rootfs-build
2022-01-14 21:54:59 +01:00
# Final stage
FROM scratch AS s6-rootfs
LABEL maintainer = "Aleksandar Puharic <aleksandar@puharic.com>"
2022-01-30 04:03:56 +01:00
COPY --from= rootfs-builder [ "/rootfs-build/" , "/" ]