This repository was archived by the owner on Feb 17, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
89 lines (71 loc) · 3.6 KB
/
Dockerfile
File metadata and controls
89 lines (71 loc) · 3.6 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
# Build stage
FROM rust:1.92.0-bookworm@sha256:9676d0547a259997add8f5924eb6b959c589ed39055338e23b99aba7958d6d31 AS builder
# Install pinned apt dependencies
RUN --mount=type=bind,source=pinned-packages-builder.txt,target=/tmp/pinned-packages-builder.txt,ro \
set -e; \
echo 'deb [check-valid-until=no] https://snapshot.debian.org/archive/debian/20250411T024939Z bookworm main' > /etc/apt/sources.list && \
echo 'deb [check-valid-until=no] https://snapshot.debian.org/archive/debian-security/20250411T024939Z bookworm-security main' >> /etc/apt/sources.list && \
echo 'Acquire::Check-Valid-Until "false";' > /etc/apt/apt.conf.d/10no-check-valid-until && \
rm -rf /etc/apt/sources.list.d/debian.sources && \
mkdir -p /etc/apt/preferences.d && \
cat /tmp/pinned-packages-builder.txt | while read line; do \
pkg=$(echo $line | cut -d= -f1); \
ver=$(echo $line | cut -d= -f2); \
if [ ! -z "$pkg" ] && [ ! -z "$ver" ]; then \
printf "Package: %s\nPin: version %s\nPin-Priority: 1001\n\n" "$pkg" "$ver" >> /etc/apt/preferences.d/pinned-packages; \
fi; \
done && \
apt-get update && \
apt-get install -y --no-install-recommends \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/* /var/log/* /var/cache/ldconfig/aux-cache
WORKDIR /app
# Fetch the latest pinned package list
RUN dpkg -l | grep '^ii' | awk '{print $2"="$3}' | sort > ./pinned-packages-builder.txt
ARG SOURCE_DATE_EPOCH=0
ENV SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH}
# Copy project files
COPY Cargo.toml Cargo.lock ./
COPY src/ ./src/
# Build the application in release mode
RUN cargo build --release --locked
# Runtime stage
FROM debian:bookworm-slim@sha256:78d2f66e0fec9e5a39fb2c72ea5e052b548df75602b5215ed01a17171529f706
# Bootstrap ca-certificates
RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates \
&& rm -rf /var/lib/apt/lists/* /var/log/* /var/cache/ldconfig/aux-cache
# Install pinned apt dependencies
RUN --mount=type=bind,source=pinned-packages-runtime.txt,target=/tmp/pinned-packages-runtime.txt,ro \
set -e; \
echo 'deb [check-valid-until=no] https://snapshot.debian.org/archive/debian/20250411T024939Z bookworm main' > /etc/apt/sources.list && \
echo 'deb [check-valid-until=no] https://snapshot.debian.org/archive/debian-security/20250411T024939Z bookworm-security main' >> /etc/apt/sources.list && \
echo 'Acquire::Check-Valid-Until "false";' > /etc/apt/apt.conf.d/10no-check-valid-until && \
rm -rf /etc/apt/sources.list.d/debian.sources && \
mkdir -p /etc/apt/preferences.d && \
cat /tmp/pinned-packages-runtime.txt | while read line; do \
pkg=$(echo $line | cut -d= -f1); \
ver=$(echo $line | cut -d= -f2); \
if [ ! -z "$pkg" ] && [ ! -z "$ver" ]; then \
printf "Package: %s\nPin: version %s\nPin-Priority: 1001\n\n" "$pkg" "$ver" >> /etc/apt/preferences.d/pinned-packages; \
fi; \
done && \
apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
libssl3 \
curl \
&& rm -rf /var/lib/apt/lists/* /var/log/* /var/cache/ldconfig/aux-cache
# Create app user
RUN useradd -m -u 1000 app \
&& sed -i -r 's/^(app:[^:]*:)[0-9]+/\10/' /etc/shadow
WORKDIR /app
# Copy the built binary
COPY --from=builder /app/target/release/tee-attestation-server /app/tee-attestation-server
# Copy the pinned package list from builder stage
COPY --from=builder --chmod=0664 /app/pinned-packages-builder.txt /app/pinned-packages-builder.txt
RUN chown -R app:app /app
USER app
EXPOSE 8300
CMD ["./tee-attestation-server"]