Deployment gap raised by rachelks on #42: the CI workflow builds `server/` and restarts `crate-api.service`, but nothing puts the built server where the service actually runs it. ## The gap `crate-api.service` on the VM has: ``` WorkingDirectory=/home/erikhfj/T19-Project-2/server ExecStart=/home/erikhfj/.nvm/versions/node/v24.21.0/bin/node dist/index.js ``` The CI deploy job builds in the runner's own workspace, `~/actions-runner-p2/_work/T19-Project-2/T19-Project-2`, and publishes only `client/dist` to `/var/www/html/project2`. The server build in that workspace never reached `~/T19-Project-2/server/dist`, so restarting `crate-api` brought back whatever process was last installed by hand. That was an early prototype copy from 23 September, which is why search errors against the newly migrated database. ## Progress - [x] `~/T19-Project-2` is a git clone of `main`, not a hand copy. The old hand copy is kept at `~/T19-Project-2-prototype-backup`. - [x] The VM can fetch from git.ntnu.no. It had no SSH key, so `~/.ssh/id_ed25519_git` was generated there and added to the account as key 3852. - [x] `.env` survives a deploy. It is gitignored, and `git checkout --force` was verified to leave it untouched (same md5 before and after). - [x] The deploy step checks out `$GITHUB_SHA` in `~/T19-Project-2`, installs, builds `server/`, restarts `crate-api`, polls for 200, and runs a smoke suite through Apache. In #45. - [x] `pnpm build` output for `server/` lands where `crate-api.service` runs it. Verified by a dry run of the deploy step against the VM on 15 October. - [ ] push to `main` deploys the server and restarts `crate-api` without a manual step. The commands are verified; the job invoking them on a real push is what the merge of #45 will show. - [x] the smoke suite runs on the VM against port 3001 after deploy. Verified by the same dry run, plus the fuller suite in `docs/VM-setup.md`. - [ ] a reboot of the VM leaves a working API. `systemctl is-enabled crate-api` is `enabled`, so it should. Not yet confirmed by an actual reboot. #42 merged on 13 October and the skip guards became hard failures in #45, so the deploy no longer skips. ## Things to get right - **`EnvironmentFile=/home/erikhfj/T19-Project-2/.env`** must survive whatever happens to that directory. It holds `DATABASE_URL`. - **Poll, do not sleep.** `Type=simple` reports `active` before Node binds the port. Measured at about 1850 ms; a fixed `sleep 2` has already caused a 503 through Apache. - **The sudoers rule** covers `restart`, `is-active` and `status` on `crate-api`. Anything else needs adding to `/etc/sudoers.d/crate-deploy` first. - **`sudo` needs NOPASSWD**, because the runner has no TTY. ## Related - #6 adds `server/` and is what makes this worth automating - #8 recorded the gap in `AGENTS.md` - #42 is where rachelks spotted it - #45 is the deploy step