hoc/Dockerfile

39 lines
1.2 KiB
Docker
Raw Normal View History

2019-04-16 16:57:24 +02:00
FROM ekidd/rust-musl-builder:stable as builder
# create new cargo project
RUN USER=rust cargo init --bin
# copy build config
COPY --chown=rust ./Cargo.lock ./Cargo.lock
2019-04-16 16:57:24 +02:00
COPY ./Cargo.toml ./Cargo.toml
# HACK: remove build-dependencies so we have at least some caching
RUN head -n $(($(grep -n "\[build-dependencies\]" Cargo.toml | cut -f1 -d:) - 1)) Cargo.toml | sed '/build.rs/d' > \
Cargo.toml2 && rm Cargo.toml && mv Cargo.toml2 Cargo.toml
2019-04-16 16:57:24 +02:00
# build to cache dependencies
RUN cargo build --release
2019-04-16 18:02:01 +02:00
# delete build cache to prevent caching issues later on
2019-04-16 16:57:24 +02:00
RUN rm -r ./target/x86_64-unknown-linux-musl/release/.fingerprint/hoc-*
# copy original Cargo.toml (HACK)
COPY ./Cargo.toml ./Cargo.toml
# we need our git folder so we can determine the commitref of HEAD
COPY ./.git ./.git
# copy source code
COPY ./static ./static
COPY ./templates ./templates
2019-04-23 19:44:08 +02:00
COPY ./build.rs ./build.rs
2019-04-16 16:57:24 +02:00
COPY ./src ./src
# build source code
RUN cargo build --release
FROM alpine:latest
2019-04-16 17:52:16 +02:00
RUN apk --no-cache add --update git
2019-04-24 00:26:23 +02:00
# once we don't need a git binary anymore, this should be enough
# FROM scratch
# COPY --from=linuxkit/ca-certificates:v0.7 / /
2019-04-16 16:57:24 +02:00
COPY --from=builder /home/rust/src/target/x86_64-unknown-linux-musl/release/hoc /hoc
2019-04-16 18:02:01 +02:00
ENTRYPOINT ["/hoc"]