-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
216 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Build and Push Docker Images | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
workflow_dispatch: | ||
|
||
env: | ||
IMAGE_NAME: humitifier-server | ||
DOCKERFILE_PATH: ./humitifier-server/Dockerfile | ||
|
||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push main image | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
file: ${{ env.DOCKERFILE_PATH }} | ||
push: true | ||
tags: | | ||
# ghcr.io/centrefordigitalhumanities/humitifier/${{ env.IMAGE_NAME }}:latest | ||
ghcr.io/centrefordigitalhumanities/humitifier/${{ env.IMAGE_NAME }}:${{ github.ref_name }} | ||
|
||
- name: Grype Scan | ||
id: scan | ||
uses: anchore/scan-action@v3 | ||
with: | ||
image: ghcr.io/centrefordigitalhumanities/humitifier/${{ env.IMAGE_NAME }}:${{ github.ref_name }} | ||
fail-build: false | ||
|
||
- name: upload Grype SARIF report | ||
uses: github/codeql-action/upload-sarif@v3 | ||
with: | ||
sarif_file: ${{ steps.scan.outputs.sarif }} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
FROM python:3.13.0-alpine3.20 AS builder | ||
|
||
ENV PYTHONUNBUFFERED=1 | ||
|
||
RUN pip install poetry && poetry config virtualenvs.in-project true | ||
RUN apk add postgresql-dev gcc musl-dev libffi-dev | ||
|
||
WORKDIR /app | ||
|
||
COPY pyproject.toml poetry.lock ./ | ||
COPY src/ ./src | ||
|
||
RUN poetry install --without dev --with=production -vvv | ||
|
||
FROM python:3.13.0-alpine3.20 | ||
|
||
WORKDIR /app | ||
|
||
RUN apk add postgresql-libs | ||
|
||
COPY --from=builder /app . | ||
COPY docker/gunicorn.conf.py ./ | ||
COPY docker/entrypoint.sh ./ | ||
|
||
RUN .venv/bin/python src/manage.py collectstatic --noinput | ||
|
||
CMD ["sh", "entrypoint.sh"] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
# Activate our venv | ||
source /app/.venv/bin/activate | ||
|
||
# Migrate the database | ||
python src/manage.py migrate | ||
|
||
# Run da server | ||
gunicorn humitifier_server.wsgi:application -c gunicorn.conf.py "$@" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import os | ||
|
||
bind = "0.0.0.0:8000" | ||
workers = 3 | ||
capture_output = True | ||
# How verbose the Gunicorn error logs should be | ||
loglevel = os.getenv("LOG_LEVEL", "WARNING") |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from os import environ | ||
|
||
get = environ.get | ||
|
||
def get_boolean(key: str, default) -> bool: | ||
return get(key, default=str(default)).lower() in ("true", "1", "yes", 't') |
This file contains 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