-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile_
60 lines (41 loc) · 1.49 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
54
55
56
57
58
59
60
FROM rustlang/rust:nightly-bookworm as build
ARG SCCACHE_VERSTION=0.5.4
RUN cd /tmp \
&& curl -fL https://github.com/mozilla/sccache/releases/download/v${SCCACHE_VERSTION}/sccache-v${SCCACHE_VERSTION}-x86_64-unknown-linux-musl.tar.gz | tar zx \
&& mv **/sccache /usr/local/bin/ \
&& rm -rf sccache-* \
&& mkdir -p /var/sccache
ENV SCCACHE_DIR /var/sccache
ENV RUSTC_WRAPPER sccache
# create a new empty shell project
RUN USER=root cargo new --bin rustify
WORKDIR /rustify
# copy over your manifests
COPY ./rust-toolchain.toml ./
# for installing toolchain
RUN rustup show
COPY ./Cargo.lock ./Cargo.toml ./build.rs ./
RUN \
--mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/var/sccache \
cargo build --release --target=x86_64-unknown-linux-gnu
RUN rm -rf /rustify*
COPY . .
ARG GIT_COMMIT_TIMESTAMP
ENV GIT_COMMIT_TIMESTAMP=${GIT_COMMIT_TIMESTAMP}
ARG GIT_SHA
ENV GIT_SHA=${GIT_SHA}
RUN \
--mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/var/sccache \
cargo build --release --target=x86_64-unknown-linux-gnu
FROM debian:bookworm
LABEL org.opencontainers.image.source=https://github.com/vtvz/rustify
ARG EXECUTABLE_PATH
RUN \
--mount=type=cache,target=/var/cache/apt \
apt-get update && apt-get install --no-install-recommends -y ca-certificates \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY --from=build /rustify/target/x86_64-unknown-linux-gnu/release/rustify /usr/local/bin/
CMD ["/usr/local/bin/rustify"]