Files
baibot-withmcp/Dockerfile

55 lines
1.3 KiB
Docker
Raw Normal View History

2024-09-12 13:44:06 +03:00
#######################################
# #
# Stage 1: building #
# #
#######################################
FROM docker.io/rust:1.98.0-slim-trixie AS build
2024-09-12 13:44:06 +03:00
RUN apt-get update && apt-get install -y build-essential pkg-config libssl-dev libsqlite3-dev
ENV CARGO_HOME=/cargo
ENV CARGO_TARGET_DIR=/target
WORKDIR /app
COPY . /app
ARG RELEASE_BUILD=true
2024-09-12 13:44:06 +03:00
RUN --mount=type=cache,target=/cargo,sharing=locked \
--mount=type=cache,target=/target,sharing=locked \
if [ "$RELEASE_BUILD" = "true" ]; then \
cargo build --release; \
else \
cargo build; \
fi
2024-09-12 13:44:06 +03:00
# Move it out of the mounted cache, so we can copy it in the next stage.
RUN --mount=type=cache,target=/target,sharing=locked \
if [ "$RELEASE_BUILD" = "true" ]; then \
cp /target/release/baibot /baibot; \
else \
cp /target/debug/baibot /baibot; \
fi
2024-09-12 13:44:06 +03:00
#######################################
# #
# Stage 2: packaging #
# #
#######################################
FROM docker.io/debian:trixie-slim
2024-09-12 13:44:06 +03:00
RUN apt-get update && apt-get install -y ca-certificates sqlite3 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
2024-09-12 13:44:06 +03:00
WORKDIR /app
COPY --from=build /baibot .
ENTRYPOINT ["/bin/sh", "-c"]
CMD ["/app/baibot"]