Files
alpine-base/Dockerfile
fithwum 6b01f608c6
Some checks failed
Build and Push Alpine RootFS and Docker Images / build-and-upload-rootfs (push) Failing after 5s
Build and Push Alpine RootFS and Docker Images / build-and-push-docker-images (push) Has been skipped
Build and Push Alpine RootFS and Docker Images / generate-changelogs (push) Has been skipped
Build and Push Alpine RootFS and Docker Images / generate-build-info (push) Has been skipped
test
2025-07-13 06:50:13 -07:00

37 lines
1.2 KiB
Docker

FROM alpine:latest AS builder
LABEL maintainer="fithwum"
WORKDIR /builder
# Install tools needed for building rootfs
RUN apk update && apk add --no-cache bash curl wget git jq ca-certificates coreutils tar gzip
# Download alpine-make-rootfs script
RUN wget https://raw.githubusercontent.com/alpinelinux/alpine-make-rootfs/master/alpine-make-rootfs \
&& chmod +x alpine-make-rootfs
# Build the rootfs
RUN ./alpine-make-rootfs \
--branch ${ALPINE_VERSION} \
--mirror http://dl-cdn.alpinelinux.org/alpine \
--packages "bash curl ca-certificates nano" \
alpine-rootfs
# Run custom script inside rootfs
COPY base-image-script/alpine-base_pt2.sh /builder/alpine-rootfs/
RUN chmod +x /builder/alpine-rootfs/alpine-base_pt2.sh && \
chroot /builder/alpine-rootfs /alpine-base_pt2.sh || true
# Clean up script
RUN rm -f /builder/alpine-rootfs/alpine-base_pt2.sh
# Package with versioned filename
RUN mkdir -p /output && \
tar -czf /output/alpine-${ALPINE_VERSION}.tar.gz -C alpine-rootfs .
# Final stage just copies the archive
FROM scratch AS export-stage
ARG ALPINE_VERSION
COPY --from=builder /output/alpine-${ALPINE_VERSION}.tar.gz /output/alpine-${ALPINE_VERSION}.tar.gz
CMD ["sleep", "infinity"]