-
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.
Merge pull request #10 from CentreForDigitalHumanities/ci/docker
Docker container & K8S related changes
- Loading branch information
Showing
28 changed files
with
828 additions
and
253 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,44 @@ | ||
# App specific | ||
certificates | ||
*.sqlite3 | ||
docker_initial_setup.sh | ||
|
||
# Common | ||
README.md | ||
|
||
# Docker | ||
docker-compose.yml | ||
Dockerfile | ||
.docker | ||
.dockerignore | ||
container.env | ||
|
||
# git | ||
.git | ||
.gitattributes | ||
.gitignore | ||
# GitHub | ||
.github | ||
|
||
## Python | ||
# Byte-compiled | ||
**/__pycache__/ | ||
**/*.py[cod] | ||
|
||
# Virtual environment | ||
.env | ||
.venv/ | ||
venv/ | ||
|
||
## Editors | ||
# Vim swap files | ||
**/*.swp | ||
|
||
# VS Code | ||
.vscode/ | ||
|
||
# JetBrains | ||
.idea | ||
|
||
# Notepad++ | ||
.editorconfig |
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,17 @@ | ||
# EditorConfig helps developers define and maintain consistent | ||
# coding styles between different editors and IDEs | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
indent_style = space | ||
indent_size = 4 | ||
max_line_length = 80 | ||
charset = utf-8 | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.py] | ||
max_line_length = 88 |
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,46 @@ | ||
name: Build and Push Docker Images | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
workflow_dispatch: | ||
|
||
env: | ||
IMAGE_NAME: development-idp | ||
DOCKERFILE_PATH: ./Dockerfile | ||
|
||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
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/development-idp/${{ env.IMAGE_NAME }}:${{ github.ref_name }} | ||
- name: Grype Scan | ||
id: scan | ||
uses: anchore/scan-action@v3 | ||
with: | ||
image: ghcr.io/centrefordigitalhumanities/development-idp/${{ 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,29 @@ | ||
FROM python:3.11-alpine3.20 | ||
|
||
ENV PYTHONUNBUFFERED=1 | ||
# Copy app | ||
WORKDIR /app | ||
COPY . /app | ||
|
||
# Install dependencies | ||
## Container dependencies | ||
RUN apk add postgresql-dev gcc musl-dev libffi-dev | ||
RUN pip install gunicorn psycopg[c] | ||
## App dependencies | ||
RUN apk add git xmlsec gettext | ||
RUN pip install -r requirements.txt | ||
|
||
# Cleanup build-only packages | ||
RUN apk del git gcc musl-dev libffi-dev | ||
|
||
# Compile messages | ||
RUN python manage.py compilemessages | ||
|
||
# Collect static files | ||
## Create public dir to store them in | ||
RUN mkdir -p /app/public/static | ||
## Collect them | ||
RUN python manage.py collectstatic --noinput | ||
|
||
EXPOSE 7000 | ||
CMD ["sh", "docker/run.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
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,11 @@ | ||
DJANGO_SECRET_KEY="django-insecure-lb=q@u4df-x0th(5u%$eye_ti#etst+5z+%2=lrh$$le3&v_y$" | ||
DJANGO_DEBUG="False" | ||
DJANGO_DEBUG_TOOLBAR="True" | ||
DJANGO_HOST="localhost:7000" | ||
DJANGO_ALLOWED_HOSTS="localhost,127.0.0.1" | ||
DJANGO_DB_TYPE="sqlite3" | ||
DJANGO_SQLLITE_FILE="/run/db/db.sqlite3" | ||
DJANGO_HTTPS="False" | ||
|
||
DJANGO_IDP_PRIVATE_KEY="/run/secrets/private_key" | ||
DJANGO_IDP_PUBLIC_CERT="/run/secrets/public_cert" |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
services: | ||
dev-idp: | ||
build: . | ||
ports: | ||
- "7000:7000" | ||
env_file: | ||
- ./container.env | ||
volumes: | ||
- ./db:/run/db | ||
networks: | ||
- default | ||
stdin_open: true | ||
tty: true | ||
secrets: | ||
- private_key | ||
- public_cert | ||
|
||
|
||
networks: | ||
default: | ||
|
||
secrets: | ||
private_key: | ||
file: ./certificates/private.key | ||
public_cert: | ||
file: ./certificates/public.cert | ||
|
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 @@ | ||
#!/bin/sh | ||
|
||
# Migrate the database | ||
python manage.py migrate | ||
|
||
# Run da server | ||
exec gunicorn testidp.wsgi:application -c gunicorn.conf.py "$@" |
Oops, something went wrong.