This commit is contained in:
parent
f4cbe1c848
commit
ba75261baf
1 changed files with 19 additions and 13 deletions
32
Dockerfile
32
Dockerfile
|
|
@ -1,6 +1,13 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
FROM rust:alpine AS chef
|
||||
RUN apk add --no-cache openssl-dev musl-dev openssl-libs-static lld git g++ make cmake
|
||||
FROM rust:1.80-slim-bookworm AS chef
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
pkg-config \
|
||||
libssl-dev \
|
||||
git \
|
||||
g++ \
|
||||
make \
|
||||
cmake \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
RUN cargo install cargo-chef
|
||||
WORKDIR /app
|
||||
|
||||
|
|
@ -12,28 +19,27 @@ 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
|
||||
cargo chef cook --release --recipe-path recipe.json
|
||||
|
||||
COPY . .
|
||||
RUN git submodule update --init
|
||||
|
||||
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
|
||||
cargo build --release && \
|
||||
mkdir -p /app/dist && \
|
||||
cp /app/target/release/spacebot /app/dist/
|
||||
|
||||
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/spacebot /app/dist/
|
||||
|
||||
FROM alpine:latest AS final
|
||||
FROM debian:bookworm-slim AS final
|
||||
WORKDIR /app
|
||||
|
||||
RUN apk add --no-cache python3 libstdc++
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
python3 \
|
||||
libssl3 \
|
||||
ca-certificates \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY --from=builder /app/dist/spacebot ./spacebot
|
||||
ENTRYPOINT ["./spacebot"]
|
||||
Loading…
Reference in a new issue