feat(docker): optimize final image to have no distro and optimize output executable more
This commit is contained in:
parent
cf17cc88d3
commit
44ecbd46a7
3 changed files with 19 additions and 11 deletions
17
Dockerfile
17
Dockerfile
|
|
@ -1,24 +1,19 @@
|
|||
FROM rust:1.85 AS builder
|
||||
FROM rust:alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN apt-get update && apt-get install protobuf-compiler -y
|
||||
RUN apk add --no-cache protobuf-dev git musl-dev lld
|
||||
|
||||
RUN git submodule update --init --recursive
|
||||
|
||||
RUN cargo build --release
|
||||
RUN RUSTFLAGS="-C relocation-model=static -C linker=ld.lld" cargo build --profile prod --target x86_64-unknown-linux-musl
|
||||
|
||||
FROM rust:1.85 AS final
|
||||
|
||||
WORKDIR /app
|
||||
FROM scratch AS final
|
||||
|
||||
# Copy the compiled binary from the builder stage
|
||||
COPY --from=builder /app/target/release/splatoon-server-rust /app/splatoon-server-rust
|
||||
|
||||
# Set executable permissions
|
||||
RUN chmod +x /app/splatoon-server-rust
|
||||
COPY --from=builder /app/target/x86_64-unknown-linux-musl/prod/splatoon-server-rust /splatoon-server-rust
|
||||
|
||||
# Command to run the application
|
||||
CMD ["/app/splatoon-server-rust"]
|
||||
ENTRYPOINT ["/splatoon-server-rust"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue