38 lines
No EOL
1.1 KiB
Docker
38 lines
No EOL
1.1 KiB
Docker
# 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
|
|
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 --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 && \
|
|
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/spacebot /app/dist/
|
|
|
|
FROM alpine:latest AS final
|
|
WORKDIR /app
|
|
|
|
RUN apk add --no-cache python3 libstdc++
|
|
|
|
COPY --from=builder /app/dist/spacebot ./spacebot
|
|
ENTRYPOINT ["./spacebot"] |