me-site/Dockerfile

48 lines
1.2 KiB
Text
Raw Normal View History

2022-11-12 01:06:21 +01:00
####################################################################################################
## Builder
####################################################################################################
FROM rust:latest AS builder
RUN rustup target add x86_64-unknown-linux-musl
RUN apt update && apt install -y musl-tools musl-dev
RUN update-ca-certificates
# Create appuser
ENV USER=actix
ENV UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
"${USER}"
2022-08-23 02:26:24 +02:00
2022-11-12 00:44:36 +01:00
WORKDIR /app
2022-11-12 01:06:21 +01:00
COPY ./ .
RUN cargo build --target x86_64-unknown-linux-musl --release
2022-08-23 02:26:24 +02:00
2022-11-12 01:06:21 +01:00
####################################################################################################
## Final image
####################################################################################################
FROM alpine
# Import from builder.
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /etc/group /etc/group
WORKDIR /app
2022-08-23 02:26:24 +02:00
2022-11-12 01:06:21 +01:00
# Copy our build
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/me-site ./
2022-08-23 02:26:24 +02:00
2022-11-12 01:06:21 +01:00
# Use an unprivileged user.
USER actix:actix
2022-09-09 16:40:44 +02:00
2022-11-12 01:06:21 +01:00
CMD ["/me-site"]