Merge branch 'optimize-docker' into 'main'
make docker containers more efficient See merge request perditum/rnex-splatoon!12
This commit is contained in:
commit
f73674b07d
3 changed files with 19 additions and 11 deletions
2
.dockerignore
Normal file
2
.dockerignore
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
.env
|
||||||
|
target
|
||||||
11
Cargo.toml
11
Cargo.toml
|
|
@ -3,6 +3,17 @@ name = "splatoon-server-rust"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
[profile.prod]
|
||||||
|
inherits = "release"
|
||||||
|
overflow-checks = false
|
||||||
|
strip = true
|
||||||
|
debug = false
|
||||||
|
debug-assertions = false
|
||||||
|
lto = true
|
||||||
|
incremental = false
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bytemuck = { version = "1.21.0", features = ["derive"] }
|
bytemuck = { version = "1.21.0", features = ["derive"] }
|
||||||
dotenv = "0.15.0"
|
dotenv = "0.15.0"
|
||||||
|
|
|
||||||
17
Dockerfile
17
Dockerfile
|
|
@ -1,24 +1,19 @@
|
||||||
FROM rust:1.85 AS builder
|
FROM rust:alpine AS builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY . .
|
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 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
|
FROM scratch AS final
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Copy the compiled binary from the builder stage
|
# Copy the compiled binary from the builder stage
|
||||||
COPY --from=builder /app/target/release/splatoon-server-rust /app/splatoon-server-rust
|
COPY --from=builder /app/target/x86_64-unknown-linux-musl/prod/splatoon-server-rust /splatoon-server-rust
|
||||||
|
|
||||||
# Set executable permissions
|
|
||||||
RUN chmod +x /app/splatoon-server-rust
|
|
||||||
|
|
||||||
# Command to run the application
|
# 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