From d13033d6d8f3c3c86781645df9c760b4dcf7baf9 Mon Sep 17 00:00:00 2001 From: Owen Rees Date: Tue, 30 Jun 2026 20:01:46 +0200 Subject: [PATCH] Hotfix/opam install pgn to tex (#2) * update to latest ocaml/opam release * remove commented out code * update pgn_to_tex version, pinning github tag * update docker container pull from registry script --- .github/workflows/production.yml | 10 +++------- .gitignore | 7 ++++--- Dockerfile | 7 ++++--- bin/pdf_handler.ml | 6 ++---- chess-scribe-api.opam | 2 +- docker-compose.yml | 1 - 6 files changed, 14 insertions(+), 19 deletions(-) diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml index f815843..bb892ef 100644 --- a/.github/workflows/production.yml +++ b/.github/workflows/production.yml @@ -21,11 +21,6 @@ jobs: - name: Login to Github Container Registry run: echo "${{ secrets.GHCR_SECRET }}" | docker login ghcr.io -u ${{ env.GH_USER }} --password-stdin - # - name: Build image and publish - # run: | - # docker build . -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - # docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -53,5 +48,6 @@ jobs: port: ${{ secrets.PORT }} script: | cd /home/${{ secrets.USERNAME }} - echo "${{ secrets.SUDO_PASSWORD }}" | sudo -S docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - echo "${{ secrets.SUDO_PASSWORD }}" | sudo -S docker compose up -d --force-recreate + echo "${{ secrets.GHCR_SECRET }}" | docker login ghcr.io -u ${{ env.GH_USER }} --password-stdin + docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + docker compose up -d diff --git a/.gitignore b/.gitignore index eb51ffb..199c1e4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ -_build/ -_opam/ -.env \ No newline at end of file +_build +_opam +.env +.idea \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index dd3c746..1d599db 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,12 @@ # --- STAGE 1: Build the native OCaml binary --- # ocaml/opam:debian-13-ocaml-5.4 -FROM ocaml/opam@sha256:a43344fd8178438c12ce3c78124f966ac44fb015c7cc4ba685f980f9a0460091 AS builder +FROM ocaml/opam@sha256:82a44b5c39729dbea10a5aa394c544e8d2f6cadd2a8d3f7656c2259c72e3e55a AS builder USER opam WORKDIR /app COPY --chown=opam:opam dune-project ./ -RUN opam update && opam install -y dune dream -RUN opam pin add -y pgn_to_tex git+https://github.com/TheRealOwenRees/pgn_to_tex.git#v0.0.1-rc.2 +RUN opam update && \ + opam pin add -y pgn_to_tex https://github.com/TheRealOwenRees/pgn_to_tex.git#v0.0.1 && \ + opam install -y dune dream pgn_to_tex COPY --chown=opam:opam . . RUN opam exec -- dune build bin/main.exe diff --git a/bin/pdf_handler.ml b/bin/pdf_handler.ml index 4bee05f..a5f3cec 100644 --- a/bin/pdf_handler.ml +++ b/bin/pdf_handler.ml @@ -69,7 +69,7 @@ let handle_convert request = let pid = Unix.create_process "pdflatex" argv Unix.stdin Unix.stdout Unix.stderr in - (* let _, process_status = Unix.waitpid [] pid in *) + let _, _ = Unix.waitpid [] pid in if Sys.file_exists pdf_file_path then ( @@ -79,7 +79,6 @@ let handle_convert request = cleanup (); - (* TODO: record_metrics "SUCCESS" start_time; *) Dream.respond ~status:`Created ~headers: [ @@ -102,7 +101,6 @@ let handle_convert request = | exn -> cleanup (); let err_msg = Printexc.to_string exn in - (* TODO: record_metrics "FAIL" start_time err_msg; *) - (* TODO: logger.error err_msg; *) + Dream.json ~status:`Internal_Server_Error (Printf.sprintf {|{"type": "error", "message": "%s"}|} err_msg) diff --git a/chess-scribe-api.opam b/chess-scribe-api.opam index 2058649..edc3762 100644 --- a/chess-scribe-api.opam +++ b/chess-scribe-api.opam @@ -8,7 +8,7 @@ authors: ["Owen Rees"] license: "AGPL-3.0-or-later" tags: ["chess" "pgn" "pdf"] homepage: "https://github.com/therealowenrees/chess-scribe-api" -doc: "https://github.com/therealowenrees/chess-scribe-api/README.md" +doc: "https://github.com/therealowenrees/chess-scribe-api/blob/main/README.md" bug-reports: "https://github.com/therealowenrees/chess-scribe-api/issues" depends: [ "dune" {>= "3.21"} diff --git a/docker-compose.yml b/docker-compose.yml index 83b0580..e735a26 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,6 @@ services: build: context: . dockerfile: Dockerfile - container_name: chess-scribe-api restart: unless-stopped ports: