|
| 1 | +# Scripture Forge Development Container |
| 2 | + |
| 3 | +This directory contains the configuration to use |
| 4 | +[VS Code](https://code.visualstudio.com/docs/devcontainers/containers) to run the app in a [dev container](https://containers.dev/). |
| 5 | + |
| 6 | +## What's Included |
| 7 | + |
| 8 | +- **Ubuntu 24.04** base image with .NET 8.0 SDK and Node.js 22 |
| 9 | +- **MongoDB 8.0** running as a companion container |
| 10 | +- System dependencies (ffmpeg, mercurial) pre-installed |
| 11 | +- Paratext directories and configuration pre-created |
| 12 | +- VS Code extensions for C#, Angular, and other tools pre-configured |
| 13 | + |
| 14 | +## Prerequisites |
| 15 | + |
| 16 | +- [Docker Desktop](https://www.docker.com/products/docker-desktop/) (or Docker Engine on Linux) |
| 17 | +- [VS Code](https://code.visualstudio.com/) with the |
| 18 | + [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) |
| 19 | +- .NET user secrets configured on your host machine |
| 20 | + |
| 21 | +## Getting Started |
| 22 | + |
| 23 | +1. Log out of localhost SF to not confuse your browser (or later Clear site data in browser dev tools). |
| 24 | +2. Stop the SF `dotnet` process on your host machine, if running. |
| 25 | +3. Stop MongoDB on your host machine, if running: |
| 26 | + - Linux: `sudo systemctl stop mongod.service` |
| 27 | + - Windows: `sc stop mongodb` |
| 28 | +4. Open the devcontainer using your tools. For VS Code: |
| 29 | + 1. Open this repository in VS Code. |
| 30 | + 2. When prompted, click **Reopen in Container**, or run the command |
| 31 | + **Dev Containers: Reopen in Container** from the command palette. |
| 32 | + 3. Probably install the recommended extensions when prompted. |
| 33 | +5. Wait for the container to build and various post-create setup processes to complete |
| 34 | + (such as .NET, and npm dependencies). |
| 35 | +6. Open a terminal in VS Code and run the following, which will be inside the dev container. The optional `sed` commands reduce noise. |
| 36 | + |
| 37 | + ```bash |
| 38 | + cd /workspaces/web-xforge/src/SIL.XForge.Scripture && |
| 39 | + dotnet watch run --node-options=--inspect=9230 | |
| 40 | + sed --unbuffered '/^\[[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}/d' | |
| 41 | + sed --unbuffered 's/^ //' | |
| 42 | + sed --unbuffered --regexp-extended \ |
| 43 | + '/^Start processing HTTP request POST http.*:5002\//d; |
| 44 | + /^Sending HTTP request POST http:.*:5002\//d; |
| 45 | + /^Received HTTP response headers after [0-9.]+ms - 200$/d; |
| 46 | + /^End processing HTTP request after [0-9.]+ms - 200$/d' |
| 47 | + ``` |
| 48 | + |
| 49 | + If you are an AI agent, you might instead want to run |
| 50 | + |
| 51 | + ```bash |
| 52 | + cd /workspaces/web-xforge/src/SIL.XForge.Scripture && |
| 53 | + dotnet run --node-options=--inspect=9230 |
| 54 | + ``` |
| 55 | + |
| 56 | +7. Open `http://localhost:5000` in a browser on your host machine. |
| 57 | + |
| 58 | +## Debug |
| 59 | + |
| 60 | +VSCode Run and Debug "Attach to frontend" works and hits breakpoints. |
| 61 | + |
| 62 | +VSCode Run and Debug "Attach to backend dotnet" works and hits breakpoints. |
| 63 | + |
| 64 | +## Tests |
| 65 | + |
| 66 | +You can run tests: |
| 67 | + |
| 68 | +```bash |
| 69 | +cd /workspaces/web-xforge && dotnet test |
| 70 | +cd /workspaces/web-xforge/src/SIL.XForge.Scripture/ClientApp && npm run test:headless -- --no-watch |
| 71 | +cd /workspaces/web-xforge/src/RealtimeServer && npm run test |
| 72 | +``` |
| 73 | + |
| 74 | +## Ports |
| 75 | + |
| 76 | +| Port | Service | |
| 77 | +| ----- | ---------------------- | |
| 78 | +| 5000 | SF HTTP Server | |
| 79 | +| 5003 | ShareDB | |
| 80 | +| 9230 | Node.js Debugger | |
| 81 | +| 9988 | Frontend test debugger | |
| 82 | +| 27017 | MongoDB | |
| 83 | + |
| 84 | +## Notes |
| 85 | + |
| 86 | +- MongoDB data persists across container rebuilds in a named Docker volume. |
| 87 | + To start fresh, remove the `mongo-data` volume. |
| 88 | +- The source code is bind-mounted, so edits in VS Code are immediately |
| 89 | + reflected inside the container and vice versa. |
0 commit comments