Merge branch 'optimize-docker' into 'main'

make docker containers more efficient

See merge request perditum/rnex-splatoon!12
This commit is contained in:
SPFN Admin 2025-03-25 07:21:45 +00:00
commit f73674b07d
3 changed files with 19 additions and 11 deletions

2
.dockerignore Normal file
View file

@ -0,0 +1,2 @@
.env
target

View file

@ -3,6 +3,17 @@ name = "splatoon-server-rust"
version = "0.1.0"
edition = "2021"
[profile.prod]
inherits = "release"
overflow-checks = false
strip = true
debug = false
debug-assertions = false
lto = true
incremental = false
[dependencies]
bytemuck = { version = "1.21.0", features = ["derive"] }
dotenv = "0.15.0"

View file

@ -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"]