-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
53 lines (38 loc) · 1.5 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
ARG FEATURES "dynamic"
FROM docker.io/library/alpine:edge AS builder
ARG FEATURES
ENV RUST_TARGET "x86_64-unknown-linux-musl"
ENV RUSTFLAGS "-Lnative=/usr/lib -Z mir-opt-level=3"
RUN apk upgrade && \
apk add curl gcc g++ musl-dev cmake make && \
curl -sSf https://sh.rustup.rs | sh -s -- --profile minimal --component rust-src --default-toolchain nightly -y
WORKDIR /build
COPY Cargo.toml Cargo.lock ./
COPY .cargo ./.cargo/
WORKDIR /build/drill-server
COPY drill-server/Cargo.toml ./
WORKDIR /build/drill-proto
COPY drill-proto/Cargo.toml ./
WORKDIR /build/drill-client
COPY drill-client/Cargo.toml ./
WORKDIR /build
RUN mkdir drill-proto/src/ && \
mkdir drill-server/src/ && \
mkdir drill-client/src/ && \
echo '' > ./drill-proto/src/lib.rs && \
echo 'fn main() {}' > ./drill-server/src/main.rs && \
echo 'fn main() {}' > ./drill-client/src/main.rs && \
source $HOME/.cargo/env && \
cargo build --release --features "$FEATURES" --target="$RUST_TARGET"
RUN rm -f target/$RUST_TARGET/release/deps/drill* && \
rm -f target/$RUST_TARGET/release/deps/libdrill*
COPY ./drill-proto/src ./drill-proto/src
COPY ./drill-server/src ./drill-server/src
COPY ./drill-client/src ./drill-client/src
RUN source $HOME/.cargo/env && \
cargo build --release --features "$FEATURES" --target="$RUST_TARGET" && \
cp target/$RUST_TARGET/release/drill-server /drill-server && \
strip /drill-server
FROM scratch
COPY --from=builder /drill-server /drill-server
ENTRYPOINT ["./drill-server"]