This commit is contained in:
parent
1b6edcced4
commit
2f989b25b4
3 changed files with 34 additions and 17 deletions
39
Dockerfile
39
Dockerfile
|
|
@ -1,20 +1,35 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
|
||||
FROM rust:alpine as builder
|
||||
|
||||
RUN apk add openssl-dev musl-dev openssl-libs-static lld git
|
||||
|
||||
FROM rust:alpine AS chef
|
||||
RUN apk add --no-cache openssl-dev musl-dev openssl-libs-static lld git g++ make
|
||||
RUN cargo install cargo-chef
|
||||
WORKDIR /app
|
||||
|
||||
FROM chef AS planner
|
||||
COPY . .
|
||||
RUN git submodule update --init
|
||||
RUN cargo chef prepare --recipe-path recipe.json
|
||||
|
||||
FROM chef AS builder
|
||||
COPY --from=planner /app/recipe.json recipe.json
|
||||
|
||||
ENV OPENSSL_LIB_DIR=/usr/lib
|
||||
ENV OPENSSL_INCLUDE_DIR=/usr/include/openssl
|
||||
ENV OPENSSL_STATIC=1
|
||||
|
||||
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||
--mount=type=cache,target=/app/target \
|
||||
cargo chef cook --release --recipe-path recipe.json --target x86_64-unknown-linux-musl
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN git submodule update --init
|
||||
|
||||
RUN OPENSSL_LIB_DIR=/usr/lib OPENSSL_INCLUDE_DIR=/usr/include/openssl OPENSSL_STATIC=1 cargo build --release --target x86_64-unknown-linux-musl
|
||||
|
||||
FROM scratch as final
|
||||
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||
--mount=type=cache,target=/app/target \
|
||||
cargo build --release --target x86_64-unknown-linux-musl && \
|
||||
mkdir -p /app/dist && \
|
||||
cp /app/target/x86_64-unknown-linux-musl/release/professor /app/dist/
|
||||
|
||||
FROM scratch AS final
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/professor ./splatie
|
||||
|
||||
ENTRYPOINT ["./splatie"]
|
||||
COPY --from=builder /app/dist/professor ./splatie
|
||||
ENTRYPOINT ["./splatie"]
|
||||
Loading…
Reference in a new issue