-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
35 lines (25 loc) · 957 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
29
30
31
32
33
34
35
# Based on http://whitfin.io/speeding-up-rust-docker-builds/
# **************************** BUILD PHASE **************************
FROM ekidd/rust-musl-builder:stable as BUILD
# create a new empty shell project
RUN USER=root cargo new --bin rustbucket
WORKDIR /home/rust/src/rustbucket
# copy over your manifests
COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml
# this build step will cache your dependencies
# Optimization to make it less annoying to tinker with cargo build
RUN cargo fetch
RUN cargo build --release
RUN rm src/*.rs
RUN ls
# copy your source tree
COPY ./src ./src/
# build for release
RUN cargo build --release
# **************************** RUN PHASE **************************
FROM alpine:latest
# copy the build artifact from the build stage
COPY --from=build /home/rust/src/rustbucket/target/x86_64-unknown-linux-musl/release/rustbucket .
# set the startup command to run your binary
ENTRYPOINT ["./rustbucket"]