FROM rust:1.90-slim-trixie AS build

ENV PKG_CONFIG_ALLOW_CROSS=1
ENV SCCACHE_DIR=/build-cache
ENV RUSTC_WRAPPER=sccache

WORKDIR .
COPY ./web ./web
COPY ./libseptastic/ ./libseptastic/
COPY ./web/assets ./assets
COPY ./web/templates ./templates


RUN apt -y update && apt install -y libssl-dev protobuf-compiler libc-dev sccache build-essential pkg-config
RUN cd web && cargo build --release

FROM debian:trixie-slim
WORKDIR /app

EXPOSE 8080
COPY --from=build /web/target/release/septastic_web /app/septastic_web
COPY --from=build /web/config.yaml /app/config.yaml
COPY web/assets /app/assets
COPY web/templates /app/templates

RUN apt -y update && apt install -y curl

ENV RUST_LOG=info
ENV EXPOSE_PORT=8080

ENTRYPOINT ["./septastic_web"]
