-
Notifications
You must be signed in to change notification settings - Fork 1
/
Containerfile
35 lines (28 loc) · 1.04 KB
/
Containerfile
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 AS builder
LABEL [email protected]
# use musl target for static binaries,
# so we can use a scratch container.
RUN rustup target add x86_64-unknown-linux-musl
# configure container layer caching,
# by prebuilding dependencies in a shell project.
RUN USER=root cargo new --bin simple-gallery
WORKDIR /simple-gallery
# copy over your manifests
COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml
COPY .cargo/config.toml .cargo/config.toml
# this build step will cache your dependencies
RUN cargo build --release
RUN rm src/*.rs
# copy your source tree
COPY ./src ./src
COPY ./files ./files
# build for release
RUN rm -f ./target/release/deps/simple_gallery*
RUN cargo build --release
# technically we could use a "scratch" image here, so only the binary is present.
# it's helpful to have a minimal OS, however, to debug e.g. volume mounts.
# FROM scratch
FROM debian:stable
COPY --from=builder /simple-gallery/target/x86_64-unknown-linux-musl/release/simple-gallery /usr/bin/simple-gallery
ENTRYPOINT ["/usr/bin/simple-gallery"]