run backend in docker container

This commit is contained in:
2026-05-27 22:37:44 +02:00
parent 34ebb6f876
commit 245a16fe9b
3 changed files with 45 additions and 1 deletions
+30
View File
@@ -0,0 +1,30 @@
# --- STAGE 1: Build the native OCaml binary ---
FROM ocaml/opam:debian-12-ocaml-5.4 AS builder
USER opam
WORKDIR /app
COPY --chown=opam:opam dune-project ./
RUN opam update && opam install -y dune dream
COPY --chown=opam:opam . .
RUN opam exec -- dune build bin/main.exe
# --- STAGE 2: Lightweight runtime environment ---
FROM debian:12-slim
WORKDIR /app
# Install native system dependencies and a minimal TeX Live profile
RUN apt-get update && apt-get install -y --no-install-recommends \
libssl3 \
libev4 \
ca-certificates \
# texlive-latex-base \
# texlive-latex-recommended \
# texlive-fonts-recommended \
# # tlmgr is the TeX Live package manager; we use it to grab chess assets
# texlive-games \
&& rm -rf /var/lib/apt/lists/*
# Copy the compiled native OCaml binary from Stage 1
COPY --from=builder /app/_build/default/bin/main.exe ./server
EXPOSE 8080
CMD ["./server"]
+2 -1
View File
@@ -1,5 +1,6 @@
let () =
Dream.run @@ Dream.logger
Dream.run ~interface:"0.0.0.0" ~port:8080
@@ Dream.logger
@@ Dream.router
[
Dream.get "/" (fun _ -> Dream.html "API Docs");
+13
View File
@@ -0,0 +1,13 @@
services:
chess-scribe-api:
build:
context: .
dockerfile: Dockerfile
container_name: chess-scribe-api
restart: unless-stopped
ports:
- "8080:8080"
environment:
- DREAM_ENV=production