forked from varu3/slack-approval
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
54 lines (49 loc) · 2.12 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
FROM rust:1.85.0-alpine@sha256:64d3fbc2db18485ab3a5211d56fec25493c71595e820c486e9b8a8ac9edbc4e8 AS base
LABEL org.opencontainers.image.source=https://github.com/Takashicc/slack-approval
LABEL org.opencontainers.image.description="Custom action to send approval request to Slack."
ARG WORKDIR=/app
ARG TARGETARCH
RUN apk add musl-dev ca-certificates
RUN set -eux; \
case "$TARGETARCH" in \
"amd64") \
wget https://github.com/mozilla/sccache/releases/download/v0.9.0/sccache-v0.9.0-x86_64-unknown-linux-musl.tar.gz \
&& tar xzf sccache-v0.9.0-x86_64-unknown-linux-musl.tar.gz \
&& mv sccache-v0.9.0-x86_64-unknown-linux-musl/sccache /usr/local/bin \
&& chmod +x /usr/local/bin/sccache \
;; \
"arm64") \
wget https://github.com/mozilla/sccache/releases/download/v0.9.0/sccache-v0.9.0-aarch64-unknown-linux-musl.tar.gz \
&& tar xzf sccache-v0.9.0-aarch64-unknown-linux-musl.tar.gz \
&& mv sccache-v0.9.0-aarch64-unknown-linux-musl/sccache /usr/local/bin/ \
&& chmod +x /usr/local/bin/sccache \
;; \
*) \
echo "Unsupported architecture: $TARGETARCH"; \
echo "Install using cargo"; \
cargo install sccache --version ^0.9.0 \
;; \
esac
RUN cargo install cargo-chef --version ^0.1.68
ENV RUSTC_WRAPPER=sccache SCCACHE_DIR=/sccache
ENV CARGO_INCREMENTAL=0
FROM base AS planner
WORKDIR ${WORKDIR}
COPY . .
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=$SCCACHE_DIR,sharing=locked \
cargo chef prepare --recipe-path recipe.json
FROM base AS builder
WORKDIR ${WORKDIR}
COPY --from=planner ${WORKDIR}/recipe.json recipe.json
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=$SCCACHE_DIR,sharing=locked \
cargo chef cook --release --recipe-path recipe.json
COPY . .
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=$SCCACHE_DIR,sharing=locked \
cargo build --release
FROM scratch
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /app/target/release/slack-approval /slack-approval
CMD [ "/slack-approval" ]