forked from chamburr/twilight-dispatch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
46 lines (32 loc) · 1.34 KB
/
Dockerfile
File metadata and controls
46 lines (32 loc) · 1.34 KB
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
FROM docker.io/library/alpine:latest AS builder
RUN apk add --no-cache curl clang gcc musl-dev lld cmake make && \
curl -sSf https://sh.rustup.rs | sh -s -- --profile minimal --default-toolchain nightly -y
ENV CC clang
ENV CFLAGS "-I/usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/ -L/usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/"
ENV RUSTFLAGS "-C link-arg=-fuse-ld=lld -C target-cpu=x86-64"
RUN rm /usr/bin/ld && \
rm /usr/bin/cc && \
ln -s /usr/bin/lld /usr/bin/ld && \
ln -s /usr/bin/clang /usr/bin/cc && \
ln -s /usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/crtbeginS.o /usr/lib/crtbeginS.o && \
ln -s /usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/crtendS.o /usr/lib/crtendS.o
WORKDIR /build
COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml
COPY ./.cargo ./.cargo
RUN mkdir src/
RUN echo 'fn main() {}' > ./src/main.rs
RUN source $HOME/.cargo/env && \
rustc --print target-cpus && \
cargo build --release
RUN rm -f target/release/deps/twilight_dispatch*
COPY ./src ./src
RUN source $HOME/.cargo/env && \
cargo build --release && \
strip /build/target/release/twilight-dispatch
FROM docker.io/library/alpine:latest
RUN adduser -S twilight-dispatch
USER twilight-dispatch
WORKDIR /twilight-dispatch
COPY --from=builder /build/target/release/twilight-dispatch /twilight-dispatch/run
CMD /twilight-dispatch/run