-
Notifications
You must be signed in to change notification settings - Fork 39
/
Dockerfile
48 lines (35 loc) · 1.21 KB
/
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
FROM rust:1.81.0 as build
ENV CARGO_BUILD_TARGET=x86_64-unknown-linux-musl
ENV DEBIAN_FRONTEND=noninteractive
RUN \
apt-get update && \
apt-get -y install ca-certificates musl-tools && \
rustup target add ${CARGO_BUILD_TARGET}
ENV PKG_CONFIG_ALLOW_CROSS=1
# Use Tini as our PID 1. This will enable signals to be handled more correctly.
#
# Note that this can't be downloaded inside the scratch container as we have no
# chmod command.
#
# TODO: Use `--init` instead when it is more well-supported (this should be the
# case by Jan 1, 2020).
ENV TINI_VERSION v0.18.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static /tini
RUN chmod +x /tini
# Build the real project.
COPY ./ ./
RUN cargo build --release
RUN \
mkdir -p /build && \
cp target/${CARGO_BUILD_TARGET}/release/rudolfs /build/ && \
strip /build/rudolfs
# Use scratch so we can get an itty-bitty-teeny-tiny image. This requires us to
# use musl when building the application.
FROM scratch
EXPOSE 8080
VOLUME ["/data"]
COPY --from=build /tini /tini
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=build /build/ /
ENTRYPOINT ["/tini", "--", "/rudolfs"]
CMD ["--cache-dir", "/data"]