forked from rootless-containers/slirp4netns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.artifact
61 lines (56 loc) · 2.41 KB
/
Dockerfile.artifact
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Usage:
# docker buildx build \
# -o /tmp/slirpbuilds \
# --build-arg SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) \
# --platform=amd64,arm64,arm,s390x,ppc64le,riscv64 \
# -f Dockerfile.artifact .
ARG LIBSLIRP_COMMIT=v4.7.0
ARG UBUNTU_VERSION=jammy-20240125
ARG XX_VERSION=1.2.1@sha256:8879a398dedf0aadaacfbd332b29ff2f84bc39ae6d4e9c0a1109db27ac5ba012
ARG REPRO_SOURCES_LIST_VERSION=v0.1.0
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
FROM --platform=$BUILDPLATFORM ubuntu:${UBUNTU_VERSION} AS build-libslirp
ARG REPRO_SOURCES_LIST_VERSION
ADD --chmod=0755 \
https://raw.githubusercontent.com/reproducible-containers/repro-sources-list.sh/${REPRO_SOURCES_LIST_VERSION}/repro-sources-list.sh \
/usr/local/bin/repro-sources-list.sh
ENV DEBIAN_FRONTEND=noninteractive
RUN \
--mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
repro-sources-list.sh && \
apt-get update && \
apt-get install -y apt-utils automake autotools-dev file make git ninja-build meson
# Set SOURCE_DATE_EPOCH after running repro-sources-list.sh, for cache efficiency
ARG SOURCE_DATE_EPOCH
RUN git clone https://git.qemu.org/libslirp.git /libslirp
WORKDIR /libslirp
ARG LIBSLIRP_COMMIT
RUN git pull && git checkout ${LIBSLIRP_COMMIT}
COPY --from=xx / /
ARG TARGETPLATFORM
# xx-apt-get cannot be used, as it clobbers /etc/apt/sources.list created by repro-sources-list.sh
RUN \
--mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
darch="$(xx-info debian-arch)" && \
dpkg --add-architecture ${darch} && \
apt-get update && \
gcc="gcc" && \
if xx-info is-cross; then gcc="gcc-$(xx-info triple)"; fi; \
apt-get install -y "${gcc}" "libglib2.0-dev:${darch}" "libcap-dev:${darch}" "libseccomp-dev:${darch}"
COPY Dockerfile.artifact.d/meson-cross /meson-cross
RUN meson_setup_flags="--default-library=both" ; \
if xx-info is-cross; then meson_setup_flags="${meson_setup_flags} --cross-file=/meson-cross/$(xx-info) -Dprefix=/usr/local/$(xx-info)"; fi ; \
meson setup ${meson_setup_flags} build && ninja -C build install
FROM build-libslirp AS build
COPY . /src
WORKDIR /src
RUN ./autogen.sh && \
./configure LDFLAGS="-static" --host=$(xx-info) && \
make && \
$(xx-info)-strip slirp4netns && \
xx-verify --static slirp4netns && \
cp -a slirp4netns /
FROM scratch
COPY --from=build /slirp4netns /slirp4netns