Implement docker build

This commit is contained in:
Valentin Brandl 2019-07-24 17:54:54 +02:00
parent 6be9b598b2
commit 2b13f0f586
No known key found for this signature in database
GPG Key ID: 30D341DD34118D7D

27
Dockerfile Normal file
View File

@ -0,0 +1,27 @@
FROM ekidd/rust-musl-builder:stable as builder
# RUN adduser -D hoc
RUN useradd -U 10001 dummy
# create new cargo project
RUN USER=rust cargo init --bin
# copy build config
COPY --chown=rust ./Cargo.lock ./Cargo.lock
COPY --chown=rust ./Cargo.toml ./Cargo.toml
# build to cache dependencies
RUN cargo build --release
# delete build cache to prevent caching issues later on
RUN rm -r ./target/x86_64-unknown-linux-musl/release/.fingerprint/gitache-*
COPY ./src ./src
# build source code
RUN cargo build --release
FROM scratch
COPY --from=builder /etc/passwd /etc/passwd
USER dummy
COPY --from=builder /home/rust/src/target/x86_64-unknown-linux-musl/release/gitache /
ENTRYPOINT ["/gitache"]