nicolas-van / multirun

A minimalist init process designed for Docker
https://nicolas-van.github.io/multirun/
MIT License
173 stars 9 forks source link

Docker Image to use in multi-stage builds #20

Closed tonybolzan closed 5 months ago

tonybolzan commented 2 years ago

You can use docker buildx to build an image from scratch on each architecture and upload to https://hub.docker.com/u/nicolasvan So we can use these images as intermediaries stages in the final build process without relying on scripts to validate the architecture. Example of Usage:

FROM debian:bullseye-slim 
...
RUN apt-get install php-fpm nginx
...
COPY --from=nicolasvan/multirun:1.1.3-glibc /multirun /usr/bin/multirun
CMD ["/usr/bin/multirun", "/usr/sbin/php-fpm",  "/usr/sbin/nginx"]

Examples files do build

Dockerfile to build multirun in Docker multi-arch

# syntax=docker/dockerfile:1
FROM debian:bullseye-slim as build
ENV DEBIAN_FRONTEND=noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN=true
WORKDIR /srv/multirun
RUN apt-get -qq update && \
    apt-get -qq install -y wget ca-certificates tar gzip cmake bats && \
    wget -q -O- https://github.com/nicolas-van/multirun/archive/refs/tags/1.1.3.tar.gz | tar -xz --strip-components 1 && \
    cmake -S . -B build && \
    cmake --build build && \
    bats tests.bats

FROM scratch
COPY --from=build /srv/multirun/build/multirun /multirun

And build with

#!/bin/bash
# Setup host if needed
docker run -it --rm --privileged tonistiigi/binfmt --install arm64
# Run Build
docker buildx build --push --platform linux/amd64    --tag nicolasvan/multirun:1.1.3-glibc .
docker buildx build --push --platform linux/arm64/v8 --tag nicolasvan/multirun:1.1.3-glibc .

You can create this build in Github Actions and change wget to a copy using content from checkout action