-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDockerfile
More file actions
29 lines (22 loc) · 763 Bytes
/
Dockerfile
File metadata and controls
29 lines (22 loc) · 763 Bytes
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
FROM ekidd/rust-musl-builder as builder
WORKDIR /home/rust/
USER rust
# Avoid having to install/build all dependencies by copying
# the Cargo files and making a dummy src/main.rs
COPY --chown=rust:rust Cargo.toml .
COPY --chown=rust:rust Cargo.lock .
RUN echo "fn main() {}" > src/main.rs
RUN cargo test
RUN cargo build --release
# We need to touch our real main.rs file or else docker will use
# the cached one.
COPY --chown=rust:rust . .
RUN touch src/main.rs
RUN cargo test
RUN cargo build --release
# Size optimization
RUN strip target/x86_64-unknown-linux-musl/release/reddit-bot
FROM alpine:latest
RUN apk --no-cache add ca-certificates
COPY --from=builder /home/rust/target/x86_64-unknown-linux-musl/release/reddit-bot .
ENTRYPOINT ["./reddit-bot"]