-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdebian.Dockerfile
52 lines (41 loc) · 1.52 KB
/
debian.Dockerfile
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
# Usage:
# docker buildx build -f debian.Dockerfile -t image:tag --build-arg='ARCH=x86_64' --platform linux/amd64 .
# docker buildx build -f debian.Dockerfile -t image:tag --build-arg='ARCH=aarch64' --platform linux/arm64 .
ARG RUST_VERSION=1.84.0
ARG APP_NAME=nittei
FROM rust:${RUST_VERSION}-slim AS builder
ARG APP_NAME
WORKDIR /app/${APP_NAME}
RUN apt update \
&& apt install -y --no-install-recommends curl openssl ca-certificates pkg-config build-essential libssl-dev \
&& apt clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN --mount=type=bind,source=bins,target=/app/${APP_NAME}/bins \
--mount=type=bind,source=crates,target=/app/${APP_NAME}/crates \
--mount=type=bind,source=clients,target=/app/${APP_NAME}/clients \
--mount=type=bind,source=Cargo.toml,target=Cargo.toml \
--mount=type=bind,source=Cargo.lock,target=Cargo.lock \
--mount=type=cache,target=/app/${APP_NAME}/target/ \
--mount=type=cache,target=/usr/local/cargo/git/db \
--mount=type=cache,target=/usr/local/cargo/registry/ \
cargo build --locked --release && \
cp ./target/release/$APP_NAME /bin/server
FROM debian:stable-slim
# Enable backtraces
ENV RUST_BACKTRACE=1
RUN apt update \
&& apt install -y openssl ca-certificates \
&& apt clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ARG UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
appuser
USER appuser
COPY --from=builder /bin/server /bin/
CMD ["/bin/server"]