-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
51 lines (32 loc) · 1.22 KB
/
Dockerfile
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
ARG _DEB_VERSION="12"
ARG PLATFORM="linux/arm64/v8"
ARG BASE="debian:${_DEB_VERSION}"
ARG BASE_PKGS="php binutils"
ARG BASE_BINS="php"
ARG BASE_PKG_INSTALL_CMD="apt-get update && apt-get install -y"
ARG GOLANG="golang:latest"
ARG BUSYBOX="busybox:latest"
ARG TARGET="gcr.io/distroless/base-nossl-debian${_DEB_VERSION}:latest"
FROM --platform="${PLATFORM}" ${GOLANG} AS golang
COPY "./" "/build"
RUN cd "/build" \
&& go get \
&& go build -o "/usr/local/bin/dependency_resolve" . \
&& cd -
FROM --platform="${PLATFORM}" ${BUSYBOX} AS busybox
FROM --platform="${PLATFORM}" ${BASE} AS base
ARG BASE_PKGS
ARG BASE_BINS
ARG BASE_PKG_INSTALL_CMD
COPY --from=golang "/usr/local/bin/dependency_resolve" "/usr/local/bin/dependency_resolve"
RUN /bin/sh -c "${BASE_PKG_INSTALL_CMD} ${BASE_PKGS}" \
&& /usr/local/bin/dependency_resolve \
$(echo ${BASE_BINS} | xargs which) \
| xargs -I {} sh -c 'mkdir -p /rootfs/$(dirname "{}") && cp -apP "{}" "/rootfs/{}" && (strip --strip-all "/rootfs/{}" || true)'
FROM --platform="${PLATFORM}" ${TARGET} AS target
ARG BASE_BINS
COPY --from=base "/rootfs" "/"
COPY --from=busybox "/bin/busybox" "/bin/busybox"
RUN ["/bin/busybox", "--install", "-s"]
USER nonroot
ENTRYPOINT ["/bin/sh"]