Implement docker build

This commit is contained in:
Valentin Brandl 2019-04-16 16:57:24 +02:00
parent 8eddedab84
commit 64ac7de831
No known key found for this signature in database
GPG Key ID: 30D341DD34118D7D
2 changed files with 24 additions and 0 deletions

1
.dockerignore Normal file
View File

@ -0,0 +1 @@
/target

23
Dockerfile Normal file
View File

@ -0,0 +1,23 @@
FROM ekidd/rust-musl-builder:stable as builder
# create new cargo project
RUN USER=rust cargo init --bin
# set last modified date to 1970-01-01 to prevent caching issues later on
# RUN touch -t 197001010000.00 src/main.rs
# copy build config
COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml
# build to cache dependencies
RUN cargo build --release
# RUN ls target/x*/release
# RUN touch -t 197001010000.00 ./target/x86_64-unknown-linux-musl/release/hoc.d
RUN rm -r ./target/x86_64-unknown-linux-musl/release/.fingerprint/hoc-*
# copy source code
COPY ./src ./src
# build source code
RUN cargo build --release
FROM alpine:latest
COPY --from=builder /home/rust/src/target/x86_64-unknown-linux-musl/release/hoc /hoc