mirror of
https://github.com/TheRealOwenRees/chess-scribe-api.git
synced 2026-07-23 01:06:56 +00:00
run backend in docker container
This commit is contained in:
+30
@@ -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
@@ -1,5 +1,6 @@
|
|||||||
let () =
|
let () =
|
||||||
Dream.run @@ Dream.logger
|
Dream.run ~interface:"0.0.0.0" ~port:8080
|
||||||
|
@@ Dream.logger
|
||||||
@@ Dream.router
|
@@ Dream.router
|
||||||
[
|
[
|
||||||
Dream.get "/" (fun _ -> Dream.html "API Docs");
|
Dream.get "/" (fun _ -> Dream.html "API Docs");
|
||||||
|
|||||||
@@ -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
|
||||||
Reference in New Issue
Block a user