FROM docker.io/library/rust:1-alpine3.23 AS builder
RUN apk add --no-cache build-base musl-dev cmake perl pkgconfig
WORKDIR /src
COPY Cargo.toml Cargo.lock rust-toolchain.toml ./
COPY lexicons ./lexicons
COPY crates ./crates
RUN cargo build --release --package knot-server
RUN strip target/release/knot-server

FROM docker.io/library/alpine:3.23
RUN apk add --no-cache ca-certificates
COPY --from=builder /src/target/release/knot-server /usr/local/bin/knot-server
EXPOSE 5555 2222
ENTRYPOINT ["/usr/local/bin/knot-server"]
CMD ["/etc/knot2/config.toml"]
