-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
29 lines (23 loc) · 850 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
FROM rust:latest as rust-builder
WORKDIR /build
# Copy Cargo files
COPY ./Cargo.toml ./
# Create fake main.rs file in src and build
RUN mkdir ./src && echo 'fn main() { panic!("Dummy Image Called!")}' > ./src/main.rs
RUN cargo build --release
# Copy source files over
RUN rm -rf ./src
COPY ./src ./src
# The last modified attribute of main.rs needs to be updated manually,
# otherwise cargo won't rebuild it.
RUN touch -a -m ./src/main.rs
RUN cargo build --release
# Second stage putting the build result into a debian jessie-slim image
FROM debian:stable-slim
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates zstd && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
COPY --from=rust-builder /build/target/release/s-backup /app/
ENV TZ=Etc/UTC
WORKDIR /app
ENTRYPOINT ["/app/s-backup"]