Update Dockerfile
This commit is contained in:
54
Dockerfile
54
Dockerfile
@@ -1,41 +1,29 @@
|
|||||||
ARG RUST_VERSION=1.75.0
|
# Global build arguments
|
||||||
ARG APP_NAME=minecraft_schematics_web
|
ARG RUST_VERSION=1.92.0
|
||||||
|
|
||||||
|
# -----------
|
||||||
|
# Build stage
|
||||||
|
# -----------
|
||||||
FROM rust:${RUST_VERSION}-slim-bullseye AS build
|
FROM rust:${RUST_VERSION}-slim-bullseye AS build
|
||||||
|
# All build operations happen here
|
||||||
# RUN apt-get update && apt-get install -y pkg-config libssl-dev
|
|
||||||
|
|
||||||
ARG APP_NAME
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
# Build the application using Docker BuildKit mounts:
|
||||||
RUN --mount=type=bind,source=src,target=src \
|
# - bind mounts for source files (not baked into the image)
|
||||||
--mount=type=bind,source=Cargo.toml,target=Cargo.toml \
|
# - cache mounts for faster incremental builds
|
||||||
--mount=type=bind,source=Cargo.lock,target=Cargo.lock \
|
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=/app/target \
|
||||||
--mount=type=cache,target=/usr/local/cargo/registry \
|
--mount=type=cache,target=/usr/local/cargo/registry \
|
||||||
<<EOF
|
cargo build --release --locked && \
|
||||||
set -e
|
install -m 0755 target/release/minecraft_schematics_web /bin/minecraft_schematics_web
|
||||||
cargo build --locked --release
|
|
||||||
cp ./target/release/$APP_NAME /bin/server
|
|
||||||
EOF
|
|
||||||
|
|
||||||
|
# -------------
|
||||||
|
# Runtime stage
|
||||||
|
# -------------
|
||||||
FROM debian:bullseye-slim AS final
|
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