# Lemmy 0.19.20, built from its tag with one change: reqwest's rustls also trusts the platform's roots
# (rustls-tls-native-roots), where the pasture's CA is, besides the roots it bundles. The release image trusts only
# those, so 0.19 could not reach any pasture peer.
FROM docker.io/library/rust:1.81-bookworm AS build
RUN git clone --depth 1 --branch 0.19.20 --recurse-submodules https://github.com/LemmyNet/lemmy.git /lemmy
WORKDIR /lemmy
RUN sed -i 's/^  "rustls-tls",$/  "rustls-tls",\n  "rustls-tls-native-roots",/' Cargo.toml && grep -q '"rustls-tls-native-roots"' Cargo.toml
RUN cargo build --release && strip target/release/lemmy_server

FROM docker.io/library/debian:bookworm-slim
RUN apt-get update && apt-get install -y --no-install-recommends libpq5 ca-certificates && rm -rf /var/lib/apt/lists/*
COPY --from=build /lemmy/target/release/lemmy_server /usr/local/bin/lemmy_server
ENTRYPOINT ["/usr/local/bin/lemmy_server"]
