forked from agntcy/slim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
97 lines (77 loc) · 2.23 KB
/
Dockerfile
File metadata and controls
97 lines (77 loc) · 2.23 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# Copyright AGNTCY Contributors (https://github.com/agntcy)
# SPDX-License-Identifier: Apache-2.0
# Build container
FROM --platform=${BUILDPLATFORM} rust:1.90-slim-bookworm AS rust
SHELL ["/bin/bash", "-euo", "pipefail", "-c"]
ARG TARGETARCH
RUN <<EOF
case ${TARGETARCH} in
"amd64")
PACKAGES="gcc-x86-64-linux-gnu g++-x86-64-linux-gnu"
;;
"arm64")
PACKAGES="gcc-aarch64-linux-gnu g++-aarch64-linux-gnu"
;;
*)
echo "Unsupported platform: ${TARGETPLATFORM}"
exit 1
;;
esac
DEBIAN_FRONTEND=noninteractive \
apt-get update && \
apt-get install --no-install-recommends -y \
curl \
file \
make \
unzip \
git \
lsb-release \
software-properties-common \
gnupg \
pkg-config \
${PACKAGES}
curl -L -o /tmp/llvm.sh https://apt.llvm.org/llvm.sh
chmod +x /tmp/llvm.sh
/tmp/llvm.sh 19
curl -1sLf 'https://dl.cloudsmith.io/public/task/task/setup.deb.sh' | bash
apt-get install -y task
EOF
# Copy source code
COPY . /app
WORKDIR /app/data-plane
RUN <<EOF
case ${TARGETARCH} in
"amd64")
RUSTARCH=x86_64-unknown-linux-gnu
;;
"arm64")
RUSTARCH=aarch64-unknown-linux-gnu
;;
*)
echo "Unsupported platform: ${TARGETPLATFORM}"
exit 1
;;
esac
# Fetch rust packages
task -v data-plane:fetch TARGET=${RUSTARCH}
# Build application
task -v data-plane:build:strip TARGET=${RUSTARCH} PROFILE=release
mv target/${RUSTARCH}/release/slim /slim
mv target/${RUSTARCH}/release/slim.dbg /slim.dbg
EOF
# Runtime images - debug executable, debug symbols and, most importantly, a shell :)
FROM debian:bookworm-slim AS slim-debug
ARG TARGETARCH
RUN ls -l /app/data-plane/target/
# copy the build artifacts from the build stage
COPY --from=rust /slim /slim
COPY --from=rust /slim.dbg /slim.dbg
# Grab libgcc from the CC image
FROM gcr.io/distroless/cc-debian12 AS libgcc-provider
# Runtime images - release executable
FROM gcr.io/distroless/base-nossl-debian12:nonroot AS slim-release
ARG TARGETARCH
# Copy libgcc from the libgcc-provider image
COPY --from=libgcc-provider /lib/*-linux-gnu/libgcc_s.so.1 /lib/
# copy the artifacts from the build stage
COPY --from=rust /slim /slim