Dockerfile -rw-r--r-- 1.2 KiB
1FROM rust:1.73 as build
2
3ENV CARGO_BUILD_TARGET=x86_64-unknown-linux-musl
4
5ENV DEBIAN_FRONTEND=noninteractive
6RUN \
7 apt-get update && \
8 apt-get -y install ca-certificates musl-tools && \
9 rustup target add ${CARGO_BUILD_TARGET}
10
11ENV PKG_CONFIG_ALLOW_CROSS=1
12
13# Use Tini as our PID 1. This will enable signals to be handled more correctly.
14#
15# Note that this can't be downloaded inside the scratch container as we have no
16# chmod command.
17#
18# TODO: Use `--init` instead when it is more well-supported (this should be the
19# case by Jan 1, 2020).
20ENV TINI_VERSION v0.18.0
21ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static /tini
22RUN chmod +x /tini
23
24# Build the real project.
25COPY ./ ./
26
27RUN cargo build --release
28
29RUN \
30 mkdir -p /build && \
31 cp target/${CARGO_BUILD_TARGET}/release/rudolfs /build/ && \
32 strip /build/rudolfs
33
34# Use scratch so we can get an itty-bitty-teeny-tiny image. This requires us to
35# use musl when building the application.
36FROM scratch
37
38EXPOSE 8080
39VOLUME ["/data"]
40
41COPY --from=build /tini /tini
42
43COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
44
45COPY --from=build /build/ /
46
47ENTRYPOINT ["/tini", "--", "/rudolfs"]
48CMD ["--cache-dir", "/data"]