Conversation
…le because of cuda dependencies
… issue earlier along with healthcheck stuff not working. All sorted now
# Conflicts: # frontend/app.py # uv.lock
… docker COPY for prometheus folder. Additionally added #!/bin/bash line to sh scripts. Fixed merge conflicts, and tested working locally and with docker containers
…leanup. Also added a deployment script for the compose.yml and related stuff
…oard for extra credit
There was a problem hiding this comment.
Pull request overview
This PR introduces Docker/Docker Compose assets to run AniZenith as a multi-container deployment (frontend, backend, monitoring stack), and adjusts Python dependency/index configuration to support installing PyTorch CPU builds.
Changes:
- Add Dockerfiles +
docker/compose.ymlfor frontend/backend, plus Prometheus/Grafana/cAdvisor/node-exporter/ngrok services. - Update FastAPI apps to use environment variables for host/port and add a backend
/healthendpoint for container healthchecks. - Reconfigure
uv/lockfiles and requirements to pulltorchfrom the PyTorch CPU index.
Reviewed changes
Copilot reviewed 17 out of 22 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
uv.lock |
Updates resolved artifacts/sources (notably pulling many packages from the PyTorch CPU index). |
README.md |
Adds Case Study 3 VM access and links; wraps Case Study 2 content in <details>. |
pyproject.toml |
Adds a uv index/source mapping intended for PyTorch CPU wheels. |
prometheus/prometheus_middleware.py |
Removes standalone Prometheus HTTP server start; exposes /metrics via the app router + middleware. |
grafana_dashboards/anizenith_monitoring_dashboard.json |
Adds a Grafana dashboard for container CPU/memory monitoring via Prometheus. |
frontend/requirements.txt |
Adds a separate requirements file for the frontend container. |
frontend/docker/.gitkeep |
Placeholder to keep the directory in Git. |
frontend/app.py |
Switches frontend runtime config to env vars; adjusts proxy backend URL construction; uses Prometheus middleware/router. |
docker/run.sh |
Adds a helper script to pull/down/up the compose stack. |
docker/prometheus.yml |
Adds Prometheus scrape config for frontend/backend/cAdvisor/node-exporter. |
docker/frontend.dockerfile |
Adds a Dockerfile to build/run the frontend container. |
docker/compose.yml |
Adds a multi-service compose stack including monitoring and tunneling. |
docker/build.sh |
Adds a helper script to build and push backend/frontend images. |
docker/backend.dockerfile |
Adds a Dockerfile to build/run the backend container (includes curl + PyTorch CPU extra index). |
backend/requirements.txt |
Adjusts pinned backend dependencies (including PyTorch CPU wheel + related version changes). |
backend/docker/.gitkeep |
Placeholder to keep the directory in Git. |
backend/app.py |
Adds /health endpoint; switches runtime config to env vars; uses Prometheus middleware/router. |
automation_scripts/establish_new_ssh_keys_for_backend.sh |
Updates SSH port used for key establishment. |
automation_scripts/deploy_containers.sh |
Adds an automated deployment script to copy compose/env files and start containers on the VM. |
.gitignore |
Ignores *.env and .run/. |
.github/workflows/run_tests.yml |
Updates CI to install backend requirements before running pytest. |
.dockerignore |
Ignores *.env and Python cache/bytecode from Docker build context. |
Comments suppressed due to low confidence (4)
frontend/app.py:26
- This f-string uses nested double quotes (
os.getenv("FRONTEND_PORT")) inside a double-quoted f-string, which is a Python syntax error. Use single quotes for the env var key (or escape the quotes) so the module can import/run.
frontend/app.py:97 - Same quoting issue as above: nested double quotes inside a double-quoted f-string makes this line invalid Python. Switch the inner getenv keys to single quotes (or otherwise avoid quote nesting).
frontend/app.py:138 int(os.getenv("FRONTEND_PORT"))will raise if the env var is unset/empty, andhost=os.getenv("FRONTEND_HOSTNAME")may bind to nothing (or default to 127.0.0.1), which will break access from other containers. Consider providing safe defaults (e.g., host 0.0.0.0 and port 7002) or validating env vars at startup with a clear error.
backend/requirements.txt:45- Including
pip==24.0in the application requirements will force a pip downgrade during installs (even though the Dockerfile upgrades pip just before). This can cause non-reproducible builds and makes dependency installation harder to reason about; prefer managing pip via the base image/build step rather than pinning it as an app dependency.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| [[tool.uv.index]] | ||
| name = "pytorch-cpu" | ||
| url = "https://download.pytorch.org/whl/cpu" |
There was a problem hiding this comment.
The added PyTorch CPU index is intended for torch, but the lockfile now resolves many unrelated packages from https://download.pytorch.org/whl/cpu (and downgrades some, e.g. certifi/urllib3). Configure the index as explicit/secondary (so only torch uses it) and re-lock, to avoid accidental global dependency changes.
| url = "https://download.pytorch.org/whl/cpu" | |
| url = "https://download.pytorch.org/whl/cpu" | |
| explicit = true |
| # Start from the base python:3.12.3-slim which also has debian:12-slim as base layer | ||
| FROM python:3.12.3-slim | ||
|
|
||
| # TODO: Add comment here |
There was a problem hiding this comment.
Leftover placeholder comment (# TODO: Add comment here). If this is meant to document why curl is installed (healthcheck), please replace the TODO with an explanatory comment or remove it.
| # TODO: Add comment here | |
| # Install curl for container health checks and service diagnostics |
ShafathZ
left a comment
There was a problem hiding this comment.
Needs few more useful comments, but code accepted
|
|
||
| # Install libraries using requirements.txt | ||
| RUN pip install --upgrade pip | ||
| RUN pip install -r backend/requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu --no-cache-dir |
There was a problem hiding this comment.
nit: Write comment that --extra-index-url is here since we are ensuring cpu version is installed (since Linux defaults to cuda version on PyPI)
| image: gcr.io/cadvisor/cadvisor:latest | ||
| container_name: anizenith_cadvisor | ||
| volumes: | ||
| - /:/rootfs:ro |
There was a problem hiding this comment.
I know professor wrote the code, but needs comments for why we require all of these volumes (example comment: cadvisor requires data from: root (/), sys (/sys), docker (/var/lib/docker), ...
|
|
||
| # Maps prometheus and grafana data to a volume outside the container (in case container is destroyed) | ||
| volumes: | ||
| # Used to persist Prometheus time-series metrics across container restarts |
There was a problem hiding this comment.
Add TODO to map to local user drive, but outside container drives (if possible)
There was a problem hiding this comment.
I added a separate TODO, as the issue is different.
Addressed in a27774a
No description provided.