-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (38 loc) · 1.79 KB
/
Dockerfile
File metadata and controls
51 lines (38 loc) · 1.79 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
# syntax=docker/dockerfile:1.2
FROM rust:1.93-slim-trixie@sha256:c0a38f5662afdb298898da1d70b909af4bda4e0acff2dc52aea6360a9b9c6956 AS server_builder
ARG TARGETARCH
ARG UPX_VERSION=5.1.0
## Statically link binary to OpenSSL libraries.
ENV OPENSSL_STATIC=yes
WORKDIR /app
# Install dependencies.
RUN set -x && \
apt-get update && \
apt-get install -y pkg-config curl libssl-dev cmake g++ protobuf-compiler curl xz-utils ca-certificates
# Download and install UPX.
RUN curl -LO https://github.com/upx/upx/releases/download/v${UPX_VERSION}/upx-${UPX_VERSION}-${TARGETARCH}_linux.tar.xz && \
tar -xf upx-${UPX_VERSION}-${TARGETARCH}_linux.tar.xz && \
mv upx-${UPX_VERSION}-${TARGETARCH}_linux/upx /usr/local/bin/ && \
rm -rf upx-${UPX_VERSION}-${TARGETARCH}_linux.tar.xz upx-${UPX_VERSION}-${TARGETARCH}_linux
# Copy assets, member crates, submodule crates, and manifest.
COPY ["./assets", "./assets"]
COPY ["./components/secutils-jwt-tools", "./components/secutils-jwt-tools"]
COPY ["./components/retrack/components/retrack-types", "./components/retrack/components/retrack-types"]
COPY ["./Cargo.lock", "./Cargo.toml", "./"]
# Fetch dependencies if they change.
RUN set -x && cargo fetch
# Copy only the files needed for the Rust build.
COPY ["./.cargo", "./.cargo"]
COPY ["./build.rs", "./"]
COPY ["./.sqlx", "./.sqlx"]
COPY ["./migrations", "./migrations"]
COPY ["./src", "./src"]
RUN --mount=type=cache,target=/app/target set -x && cargo build --release && \
cp ./target/release/secutils ./ && \
upx --best --lzma ./secutils
# Check out https://gcr.io/distroless/cc-debian13:nonroot
FROM gcr.io/distroless/cc-debian13:nonroot@sha256:9c4fe2381c2e6d53c4cfdefeff6edbd2a67ec7713e2c3ca6653806cbdbf27a1e
EXPOSE 7070
WORKDIR /app
COPY --from=server_builder ["/app/secutils", "./"]
CMD [ "./secutils" ]