Repository navigation
Deploy: add Google Cloud deployment (Compute Engine VM and Cloud Run) - #32
Merged
Merged
Conversation
When an attempt's result becomes final (fully auto-graded on submit, or when the last essay is graded), an "exam.result_ready" event is written to outbox_events in the same transaction as the grade. OutboxRelay publishes pending rows in the background so the student can be e-mailed. - Off by default (APP_NOTIFY_EXAM_RESULTS=false): no outbox beans, no relay, resultReady() is a no-op. Existing deployments behave as before. - Publishers: "log" (local development, default) or "pubsub" (Google Cloud Pub/Sub over REST, authenticated with the VM's service account through the metadata server; no key file). - One event per attempt (unique event_type + aggregate_id); later re-grades do not send it again. Rows are locked with SKIP LOCKED so several instances can run the relay. Failed publishes are retried up to app.outbox.max-attempts. - The score is only included when the exam shows results to students. - V5 migration adds the outbox_events table. Frontend: the backend address Nginx proxies /api and /ws to is now BACKEND_UPSTREAM (default backend:8080, unchanged for Docker Compose), so the same image also works on Cloud Run where both containers share localhost.
…d Run)
Two optional ways to run the app on Google Cloud. The existing VPS setup
(docker-compose.prod.yml, deploy.sh) is unchanged and does not read any of it.
- deploy/gcp: one Compute Engine VM running docker-compose.gcp.yml, with
PostgreSQL on Cloud SQL (Auth Proxy), uploads in Cloud Storage (S3 API + HMAC
key), images from Artifact Registry, logs in Cloud Logging, TLS via certbot.
Numbered gcloud scripts (foundation, Cloud SQL, VM, functions, teardown);
secrets are generated into Secret Manager and rendered into the VM's .env.
- deploy/cloudrun: Terraform for a Cloud Run service (frontend + backend
containers), Cloud SQL, Memorystore and Secret Manager.
- functions/: Cloud Run functions
- exam-result-mailer: e-mails students from the exam.result_ready Pub/Sub
events (deduplicated by event id)
- sql-export: scheduled Cloud SQL export to Cloud Storage
- upload-inspector: checks uploaded files against their declared type
- .gitignore: Terraform state and tfvars (they hold secrets and project ids).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two optional ways to run the app on Google Cloud. The existing VPS setup (
docker-compose.prod.yml,deploy.sh) is unchanged and does not read any of these files.Depends on the exam-result outbox PR, which adds the Pub/Sub publisher and
BACKEND_UPSTREAM.Contents
deploy/gcp/: one Compute Engine VM runningdocker-compose.gcp.yml.gcloudscripts: foundation, Cloud SQL, VM, functions, teardown..env. Nothing secret is stored in the repo.deploy/cloudrun/: Terraform for a Cloud Run service (frontend + backend containers), Cloud SQL, Memorystore and Secret Manager.functions/: Cloud Run functions.exam-result-mailer: e-mails students fromexam.result_readyevents, deduplicated by event id.sql-export: scheduled Cloud SQL export to Cloud Storage.upload-inspector: checks uploaded files against their declared type..gitignore: Terraform state and tfvars, which hold secrets and project ids.Testing
node --testin each function: 16 tests, 0 failures.bash -non every deploy script;docker compose -f docker-compose.gcp.yml configpasses.terraform validatefordeploy/cloudrun, and a real run of the scripts against a GCP project.