Skip to content

DockerFiles and Docker Compose for multiple containers#31

Merged
ShafathZ merged 17 commits into
mainfrom
docker
Apr 8, 2026
Merged

DockerFiles and Docker Compose for multiple containers#31
ShafathZ merged 17 commits into
mainfrom
docker

Conversation

@Suryanshg
Copy link
Copy Markdown
Collaborator

No description provided.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.yml for frontend/backend, plus Prometheus/Grafana/cAdvisor/node-exporter/ngrok services.
  • Update FastAPI apps to use environment variables for host/port and add a backend /health endpoint for container healthchecks.
  • Reconfigure uv/lockfiles and requirements to pull torch from 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, and host=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.0 in 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.

Comment thread pyproject.toml

[[tool.uv.index]]
name = "pytorch-cpu"
url = "https://download.pytorch.org/whl/cpu"
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
url = "https://download.pytorch.org/whl/cpu"
url = "https://download.pytorch.org/whl/cpu"
explicit = true

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in commit: 1fdbba4

Comment thread docker/backend.dockerfile Outdated
# 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
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
# TODO: Add comment here
# Install curl for container health checks and service diagnostics

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in commit: 1fdbba4

Repository owner deleted a comment from Copilot AI Apr 6, 2026
Repository owner deleted a comment from Copilot AI Apr 6, 2026
Repository owner deleted a comment from Copilot AI Apr 6, 2026
Repository owner deleted a comment from Copilot AI Apr 6, 2026
Repository owner deleted a comment from Copilot AI Apr 6, 2026
Repository owner deleted a comment from Copilot AI Apr 6, 2026
Copy link
Copy Markdown
Owner

@ShafathZ ShafathZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs few more useful comments, but code accepted

Comment thread docker/backend.dockerfile

# 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
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Addressed in a27774a

Comment thread docker/compose.yml
image: gcr.io/cadvisor/cadvisor:latest
container_name: anizenith_cadvisor
volumes:
- /:/rootfs:ro
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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), ...

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Addressed in a27774a

Comment thread docker/compose.yml

# 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
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add TODO to map to local user drive, but outside container drives (if possible)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a separate TODO, as the issue is different.
Addressed in a27774a

@ShafathZ ShafathZ merged commit 70c32f8 into main Apr 8, 2026
2 checks passed
@ShafathZ ShafathZ deleted the docker branch April 17, 2026 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants