optimize the production dockerfile to produce a 2.5MB image

This commit is contained in:
blek 2023-10-09 23:54:14 +10:00
parent 7a0b197dc6
commit 5fbb8fdc9c
Signed by: blek
GPG Key ID: 14546221E3595D0C
2 changed files with 8 additions and 1 deletions

View File

@ -23,3 +23,7 @@ sha2 = "0.10.8"
static_dir = "0.2.0"
tokio = { version = "1.32.0", features = ["rt", "macros", "rt-multi-thread"] }
warp = "0.3.6"
[profile.release]
opt-level = 'z'
lto = true

View File

@ -4,10 +4,13 @@ FROM rust:alpine as builder
WORKDIR /opt/build
COPY . .
RUN apk add --no-cache musl-dev upx
RUN cargo b -r
RUN strip target/release/filed && upx --best target/release/filed
# --- deploy ---
FROM alpine
FROM busybox:musl
COPY --from=builder /opt/build/target/release/filed /bin/filed
CMD [ "/bin/filed" ]