-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
55 lines (40 loc) · 1.29 KB
/
Dockerfile
File metadata and controls
55 lines (40 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# syntax=docker/dockerfile:1
ARG RUST_VERSION=1.84
ARG APP_NAME=rsomhap
################################################################################
# Build stage
FROM rust:${RUST_VERSION} AS builder
ARG APP_NAME
WORKDIR /usr/src/app
COPY Cargo.toml Cargo.lock ./
COPY src ./src
RUN --mount=type=cache,target=/usr/src/app/target \
--mount=type=cache,target=/usr/local/cargo/registry \
cargo build --release --locked --bin ${APP_NAME} \
&& cp ./target/release/${APP_NAME} ./${APP_NAME}
################################################################################
# Runtime stage
FROM debian:bookworm-slim AS final
ARG APP_NAME
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates curl \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /usr/src/app
ARG UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
appuser
# Copy the executable from the build stage.
COPY --from=builder --chown=appuser:appuser /usr/src/app/${APP_NAME} .
# Copy the necessary files.
COPY --chown=appuser:appuser templates ./templates
COPY --chown=appuser:appuser static ./static
COPY --chown=appuser:appuser config.toml ./
USER appuser
EXPOSE 5299
CMD ["./rsomhap"]