-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
35 lines (28 loc) · 944 Bytes
/
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
FROM rust:1.76-alpine as builder
RUN rustup target add x86_64-unknown-linux-musl
RUN apk add --no-cache musl-dev git
ENV USER=www
ENV UID=1000
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--no-create-home \
--shell "/sbin/nologin" \
--uid "${UID}" \
"${USER}"
WORKDIR /app
RUN cargo new www-redirector
WORKDIR /app/www-redirector
COPY Cargo.toml Cargo.lock ./
RUN cargo fetch --target x86_64-unknown-linux-musl --config net.git-fetch-with-cli=true
COPY src ./src
RUN cargo build --release --target x86_64-unknown-linux-musl --config net.git-fetch-with-cli=true
RUN strip target/x86_64-unknown-linux-musl/release/www-redirector
FROM scratch
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /etc/group /etc/group
WORKDIR /app
COPY --from=builder /app/www-redirector/target/x86_64-unknown-linux-musl/release/www-redirector /app/www-redirector
USER www:www
CMD ["/app/www-redirector"]