Update Dockerfile
This commit is contained in:
54
Dockerfile
54
Dockerfile
@@ -1,41 +1,29 @@
|
||||
ARG RUST_VERSION=1.75.0
|
||||
ARG APP_NAME=minecraft_schematics_web
|
||||
# Global build arguments
|
||||
ARG RUST_VERSION=1.92.0
|
||||
|
||||
# -----------
|
||||
# Build stage
|
||||
# -----------
|
||||
FROM rust:${RUST_VERSION}-slim-bullseye AS build
|
||||
|
||||
# RUN apt-get update && apt-get install -y pkg-config libssl-dev
|
||||
|
||||
ARG APP_NAME
|
||||
# All build operations happen here
|
||||
WORKDIR /app
|
||||
|
||||
RUN --mount=type=bind,source=src,target=src \
|
||||
--mount=type=bind,source=Cargo.toml,target=Cargo.toml \
|
||||
--mount=type=bind,source=Cargo.lock,target=Cargo.lock \
|
||||
# Build the application using Docker BuildKit mounts:
|
||||
# - bind mounts for source files (not baked into the image)
|
||||
# - cache mounts for faster incremental builds
|
||||
RUN --mount=type=bind,source=src,target=src,readonly \
|
||||
--mount=type=bind,source=Cargo.toml,target=Cargo.toml,readonly \
|
||||
--mount=type=bind,source=Cargo.lock,target=Cargo.lock,readonly \
|
||||
--mount=type=cache,target=/app/target \
|
||||
--mount=type=cache,target=/usr/local/cargo/registry \
|
||||
<<EOF
|
||||
set -e
|
||||
cargo build --locked --release
|
||||
cp ./target/release/$APP_NAME /bin/server
|
||||
EOF
|
||||
cargo build --release --locked && \
|
||||
install -m 0755 target/release/minecraft_schematics_web /bin/minecraft_schematics_web
|
||||
|
||||
# -------------
|
||||
# Runtime stage
|
||||
# -------------
|
||||
FROM debian:bullseye-slim AS final
|
||||
# Copy only the compiled binary from the build stage
|
||||
COPY --from=build /bin/minecraft_schematics_web /bin/
|
||||
# Run the binary
|
||||
CMD ["/bin/minecraft_schematics_web"]
|
||||
|
||||
# RUN apt-get update && apt-get install -y ca-certificates
|
||||
|
||||
ENV PUID=1000 PGID=1000
|
||||
|
||||
RUN adduser \
|
||||
--disabled-password \
|
||||
--gecos "" \
|
||||
--home "/nonexistent" \
|
||||
--shell "/sbin/nologin" \
|
||||
--no-create-home \
|
||||
--uid "${PUID}" \
|
||||
appuser
|
||||
|
||||
USER appuser
|
||||
|
||||
COPY --from=build /bin/server /bin/
|
||||
|
||||
CMD ["/bin/server"]
|
||||
|
||||
Reference in New Issue
Block a user