-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
62 lines (48 loc) · 1.26 KB
/
Dockerfile
File metadata and controls
62 lines (48 loc) · 1.26 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
56
57
58
59
60
61
62
# syntax=docker/dockerfile:1
ARG RUST_VERSION=1.94.0
ARG APP_NAME=agent-kitten
ARG UID=10001
FROM rust:${RUST_VERSION}-trixie AS build
ARG APP_NAME
ARG UID
ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /app
RUN apt-get update \
&& apt-get install -y \
cmake \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY Cargo.toml Cargo.lock build.rs ./
COPY src/ ./src/
RUN --mount=type=cache,target=/app/target/ \
--mount=type=cache,target=/usr/local/cargo/registry/ \
cargo build --locked --release && cp target/release/${APP_NAME} /bin/server
FROM debian:trixie-slim AS final
ARG APP_NAME
ARG UID
LABEL vendor="ClowderTech LLC" \
maintainer="ClowderTech LLC"
ENV DEBIAN_FRONTEND=noninteractive
RUN groupadd \
--gid "${UID}" \
--system \
appuser \
&& useradd \
--home-dir "/nonexistent" \
--shell "/usr/sbin/nologin" \
--uid "${UID}" \
--gid "${UID}" \
--no-log-init \
--system \
appuser
# Install only what's needed to run the binary
RUN apt-get update \
&& apt-get install -y \
ca-certificates \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
USER appuser
# Copy the compiled binary from the build stage
COPY --from=build /bin/server /bin/server
# Start the server
CMD ["/bin/server"]