Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Containerize Gantry #10

Merged
merged 9 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# from https://github.com/GoogleContainerTools/distroless/blob/main/examples/python3-requirements/Dockerfile

# Build a virtualenv using the appropriate Debian release
# * Install python3-venv for the built-in Python3 venv module (not installed by default)
# * Install gcc libpython3-dev to compile C Python modules
# * In the virtualenv: Update pip setuputils and wheel to support building new packages
FROM debian:12-slim AS build
RUN apt-get update && \
apt-get install --no-install-suggests --no-install-recommends --yes python3-venv gcc libpython3-dev && \
python3 -m venv /venv && \
/venv/bin/pip install --upgrade pip setuptools wheel
COPY requirements.txt /requirements.txt
RUN /venv/bin/pip install --disable-pip-version-check -r /requirements.txt

# Copy the virtualenv into a distroless image
FROM gcr.io/distroless/python3-debian12:nonroot
COPY --from=build /venv /venv
COPY ./gantry /app/gantry
WORKDIR /app
ENTRYPOINT ["/venv/bin/python", "-m", "gantry"]
33 changes: 33 additions & 0 deletions docs/deploy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Deploy

Gantry is distributed via containers. You can build an image using your favorite container engine:

```bash
podman build -t gantry .
```

In order for the application to run, you'll need to supply two things to the image: environment variables and a database file.

When running locally, you can get by with supplying an env file and volume, like so:

```bash
podman run -it -p 8080:8080 --env-file .env -v LOCAL_DB_PATH:DB_FILE gantry
```

Where `LOCAL_DB_PATH` is the absolute path to the database file on your local system. `DB_FILE` is where you would like the application to access the database. Make sure this lines up with your environment.

When running Gantry within Kubernetes, you could use [persistent volumes](https://kubernetes.io/docs/concepts/storage/persistent-volumes/). The only requirement is that the database should exist outside the container for backup and persistence purposes.

## Environment

The following variables should be exposed to the container. Those **bolded** are required and do not have defaults set in the application.

- **`PROMETHEUS_URL`** - should end in `/api/v1`
- `PROMETHEUS_COOKIE` - only needed when Prometheus requires authentication
- **`GITLAB_URL`** - should end in the endpoint for the Spack project API: `/api/v4/projects/2`
- **`GITLAB_API_TOKEN`** - this token should have API read access
- **`GITLAB_WEBHOOK_TOKEN`** - coordinate this value with the collection webhook
- **`DB_FILE`** - path where the application can access the SQLite file
- `MAX_GET_SIZE` - the maximum `GET` request (in bytes), default is 8MB
- `GANTRY_HOST` - web app hostname, default is `localhost`
- `GANTRY_PORT` - web app port, default is `8080`
2 changes: 1 addition & 1 deletion docs/home.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
2. [Data Collection](data-collection.md)
3. [Architecture](arch.md)
4. [Prediction](prediction.md)

5. [Deployment](deploy.md)
8 changes: 8 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
aiohttp==3.9.3
aiosignal==1.3.1
aiosqlite==0.19.0
attrs==23.2.0
frozenlist==1.4.1
idna==3.6
multidict==6.0.5
yarl==1.9.4
Loading