Skip to content
Closed
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
10 changes: 8 additions & 2 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,21 @@

#### File: [development_pipeline.yml](development_pipeline.yml)

**Event:** On Pull Request → any branch into develop
**Event:** On Pull Request → any branch into develop, and on push to develop

**Jobs:**

- Install dependencies (caches)
- Audit runtime dependencies with pip-audit
- Run isort
- Run black
- Run flake8
- Run unit and integration tests (`python -m flask tests` against a PostgreSQL service container)
- Build images (caches)
- Push images to Docker Hub

**Description:**
This workflow is triggered on Pull Requests into the develop branch. It ensures a clean and standardized codebase by installing dependencies, checking code formatting with isort, black, and flake8, and finally building and pushing Docker images to Docker Hub.
This workflow is triggered on Pull Requests into the develop branch and on every push to it. It ensures a clean and standardized codebase by installing dependencies, auditing the runtime dependencies for known vulnerabilities with pip-audit, checking code formatting with isort, black, and flake8, running the test suite, and finally building and pushing Docker images to Docker Hub.

### Staging - CI/CD Pipeline

Expand All @@ -50,9 +52,11 @@ This workflow is triggered on Pull Requests into the develop branch. It ensures
**Jobs:**

- Install dependencies (caches)
- Audit runtime dependencies with pip-audit
- Run isort
- Run black
- Run flake8
- Run unit and integration tests (`python -m flask tests` against a PostgreSQL service container)
- Build images (caches)
- Push images to Docker Hub
- Create infrastructure
Expand All @@ -72,9 +76,11 @@ This pipeline is designed for the staging environment and is triggered on Pull R
**Jobs:**

- Install dependencies (caches)
- Audit runtime dependencies with pip-audit
- Run isort
- Run black
- Run flake8
- Run unit and integration tests (`python -m flask tests` against a PostgreSQL service container)
- Build images (caches)
- Push images to Docker Hub
- Create infrastructure
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cloudformations/server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Parameters:
AMItoUse:
Description: AMI to use for our base image - Canonical, Ubuntu, 22.04 LTS, amd64 jammy image build on 2023-05-16
Type: String
Default: "ami-053b0d53c279acc90"
Default: "ami-key"

Resources:
VPC:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/development_pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ jobs:
cache: "pip"

- name: Install Python dependencies
run: python -m pip install -r requirements.txt
run: python -m pip install -r requirements-dev.txt

- name: Audit runtime dependencies for known vulnerabilities
run: pip-audit -r requirements.txt

- name: Run isort
run: isort --check-only --profile=black .
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/production_pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ jobs:
cache: "pip"

- name: Install Python dependencies
run: python -m pip install -r requirements.txt
run: python -m pip install -r requirements-dev.txt

- name: Audit runtime dependencies for known vulnerabilities
run: pip-audit -r requirements.txt

- name: Run isort
run: isort --check-only --profile=black .
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/staging_pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ jobs:
cache: "pip"

- name: Install Python dependencies
run: python -m pip install -r requirements.txt
run: python -m pip install -r requirements-dev.txt

- name: Audit runtime dependencies for known vulnerabilities
run: pip-audit -r requirements.txt

- name: Run isort
run: isort --check-only --profile=black .
Expand Down
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,11 @@ celerybeat.pid
# SageMath parsed files
*.sage.py

# Environment variable
# .env
# .env*
# Environment variable (real env files must never be committed; templates are allowed)
.env
.env*
!.env.example
!.env.*.example

# Environments
.venv/
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.terminal.useEnvFile": true
}
37 changes: 24 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
FROM python:3.10.9-slim
FROM python:3.10-slim

WORKDIR /app

# Update the package lists and install the PostgreSQL client
# postgresql-client provides psql, used by entrypoint.sh to wait for the database
RUN apt-get update && \
apt-get install -y postgresql-client && \
apt clean && \
rm -rf /var/cache/apt/*
apt-get install -y --no-install-recommends postgresql-client && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONIOENCODING=utf-8
PYTHONIOENCODING=utf-8 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1

COPY requirements.txt /app
# Runtime dependencies only (no linters, test tools or notebooks in the image)
COPY requirements.txt /app/
RUN pip install --upgrade pip && \
pip install -r requirements.txt

RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt
# Unprivileged user. uid/gid 1000 so that the ./logs bind mount in
# docker-compose.yml stays writable on a typical single-user host.
RUN groupadd --gid 1000 app && \
useradd --uid 1000 --gid app --no-create-home --shell /usr/sbin/nologin app && \
mkdir -p /app/logs && \
chown app:app /app /app/logs

COPY . /app
COPY --chown=app:app . /app

# Chmod to entrypoint.sh
RUN chmod +x ./entrypoint.sh
RUN chmod +x /app/entrypoint.sh

USER app

EXPOSE 5000

# Run entrypoint.sh
ENTRYPOINT ["/app/entrypoint.sh"]
Loading