From 28a46f2f8045caf0afa3c35fe2c6cf40915ddf78 Mon Sep 17 00:00:00 2001 From: Xander Vertegaal Date: Mon, 20 Oct 2025 17:41:57 +0200 Subject: [PATCH] Apply migrations in backend; add prebuild instructions to frontend --- README.md | 12 ++++++++++-- backend/Dockerfile | 10 ++++++++-- backend/entrypoint.sh | 8 ++++++++ frontend/Dockerfile.dev | 3 +++ 4 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 backend/entrypoint.sh diff --git a/README.md b/README.md index e98b196..c2ede20 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,8 @@ In overview, your file structure should be as follows. | └── Dockerfile | ├── mg-parser-server -| └── Dockerfile +| ├── Dockerfile +| └── model.tar.gz | └── vulcan-parseport ├── Dockerfile @@ -63,6 +64,7 @@ Note that you will need three data files in order to run this project. - `model_weights.pt` should be put in the root directory of the `spindle-server` project. It can be downloaded from _Yoda-link here_. - `aethel.pickle` contains the pre-parsed data for Æthel and should live at `parseport/backend/aethel_db/data`. You can find it in the zip archive [here](https://github.com/konstantinosKokos/aethel/tree/stable/data). - `standard.pickle` contains the pre-parsed corpus for the Minimalist Parser. It should be placed in the `vulcan-parseport/app` directory. You can download it from _Yoda-link here_. +- `model.tar.gz` should be put in the root directory of the `mg-parser-server` project. It can be downloaded from _Yoda-link here_. This application can be run in both `production` and `development` mode. Either mode will start a network of seven containers. @@ -76,6 +78,8 @@ This application can be run in both `production` and `development` mode. Either | `pp-mg-parser` | The server hosting the Minimalist Grammar parser. | | `pp-vulcan` | The server hosting the Vulcan visualization tool. | +Before starting your container, make sure to run `yarn run prebuild` in the `frontend` directory to generate the `version.ts` file required for the frontend build. + Start the Docker network in **development mode** by running the following command in your terminal. ```bash @@ -94,7 +98,11 @@ Open your browser and visit your project at http://localhost:5001 to view the ap ## Preparing for development -Note that the Aethel dataset will be loaded in every time the backend server restarts. To avoid slow feedback loops in a development environment, consider running `python manage.py create_aethel_subset` before starting the development server. This will take create a much smaller subset that takes less than a second to load. +The Aethel dataset (in `aethel.pickle`) will be loaded in every time the backend server restarts. To avoid slow feedback loops in a development environment, consider running the Django `create_aethel_subset` management command in `backend` before starting the development server. This will take create a much smaller subset that takes less than a second to load. You will need to specify your source file (the full pickle) and the path to the new subset file. The following will work for development purposes. Note that `settings.py` will look for these paths, so adjust them accordingly if you place the files elsewhere. + +```bash +python manage.py create_aethel_subset .\aethel_db\data\aethel.pickle .\aethel_db\data\aethel_subset.pickle +``` ## Before you start diff --git a/backend/Dockerfile b/backend/Dockerfile index 025722c..d6d60e8 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,8 +1,8 @@ FROM python:3.10-bullseye # Set environment variables -ENV PYTHONDONTWRITEBYTECODE 1 -ENV PYTHONUNBUFFERED 1 +ENV PYTHONDONTWRITEBYTECODE=1 +ENV PYTHONUNBUFFERED=1 # Install dependencies RUN apt update @@ -21,5 +21,11 @@ COPY . /src/ # Create a directory for Gunicorn logs (production). RUN mkdir -p /logs +# Copy and set permissions for entrypoint script +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + # Expose port EXPOSE 8000 + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/backend/entrypoint.sh b/backend/entrypoint.sh new file mode 100644 index 0000000..7666314 --- /dev/null +++ b/backend/entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -e + +echo "Running Django migrations..." +python manage.py migrate --noinput + +echo "Starting Django server..." +exec "$@" diff --git a/frontend/Dockerfile.dev b/frontend/Dockerfile.dev index 9de028f..ffe695c 100644 --- a/frontend/Dockerfile.dev +++ b/frontend/Dockerfile.dev @@ -10,5 +10,8 @@ COPY package.json yarn.lock ./ RUN yarn global add @angular/cli@17 RUN yarn install +# Generated by build-pre.js. See the README for more details. +COPY src/environments/version.ts ./src/environments/version.ts + # Expose the port used by the development server. EXPOSE 4200