# syntax=docker/dockerfile:1
# Cartonization 1.0.0 for Linux x64: a ready-to-use image of the binary in this directory.
#
#   docker build -t cartonization:1.0.0 .
#   docker run -d --name cartonization -p 10081:10081 cartonization:1.0.0
#
# The binary is a self-contained executable (Node.js v24.22.1 inside) built for glibc. Any glibc-based base works
# (Debian, Ubuntu, Red Hat UBI, gcr.io/distroless/cc-debian12): replace the FROM line with your approved image of the
# same architecture. Alpine (musl) is not supported.
FROM --platform=linux/amd64 debian:bookworm-slim

COPY --chown=root:root cartonization /usr/local/bin/cartonization
COPY --chown=root:root EULA.txt NOTICE.txt /usr/share/doc/cartonization/

# Configuration is environment only: PORT, HOST, LICENSE_KEY or LICENSE_FILE (your license key; without either the
# embedded evaluation license is used and results are marked TRIAL), SOLVER_MAX_CONCURRENT, SOLVER_TIMEOUT_MS,
# CARTONIZATION_INSTANCE_ID (give the container a fixed id: its hostname changes with every container).
# The server writes nothing: no volume needed, a read-only root filesystem works.
ENV PORT=10081 \
    HOST=0.0.0.0

# Unprivileged user (no entry in /etc/passwd needed).
USER 10001:10001
EXPOSE 10081
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 CMD ["cartonization", "health"]
# `serve` by default; other subcommands run as one-off containers, e.g. `docker run --rm cartonization:1.0.0 version`.
ENTRYPOINT ["cartonization"]
CMD ["serve"]
