Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Fs 4462 base images #4

Merged
merged 9 commits into from
Jul 12, 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
10 changes: 6 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ jobs:
docker-build:
strategy:
matrix:
flavour: ["flask", "frontend"]
flavour: ["flask", "frontend", "db"]
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./python-flask-dev
working-directory: ./python-flask
steps:
- name: Checkout repo
uses: actions/checkout@v4
Expand All @@ -26,6 +26,7 @@ jobs:
echo "PYTHON_FLASK_DEV_PYTHON=$PYTHON_FLASK_DEV_PY" >> $GITHUB_ENV
echo "PYTHON_FLASK_DEV_FLASK=$PYTHON_FLASK_DEV_FLASK" >> $GITHUB_ENV
echo "PYTHON_FLASK_DEV_FRONTEND=$PYTHON_FLASK_DEV_JINJA" >> $GITHUB_ENV
echo "PYTHON_FLASK_DEV_DB=$PYTHON_FLASK_DEV_SQL_ALCHEMY" >> $GITHUB_ENV

- name: Docker metadata
id: metadata
Expand All @@ -38,6 +39,7 @@ jobs:
type=raw,value=${{env.PYTHON_FLASK_DEV_PYTHON}},enable=${{ github.ref == format('refs/heads/{0}', 'main')}}
type=raw,value=${{env.PYTHON_FLASK_DEV_FLASK}},enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=raw,value=${{env.PYTHON_FLASK_DEV_FRONTEND}},enable=${{ (github.ref == format('refs/heads/{0}', 'main')) && (matrix.flavour == 'frontend') }}
type=raw,value=${{env.PYTHON_FLASK_DEV_DB}},enable=${{ (github.ref == format('refs/heads/{0}', 'main')) && (matrix.flavour == 'db') }}
type=ref,event=branch

- name: Log in to the Container registry
Expand All @@ -50,9 +52,9 @@ jobs:
- name: Build and push docker image
uses: docker/build-push-action@v4
with:
context: ./python-flask-dev/
context: ./python-flask/
tags: ${{ steps.metadata.outputs.tags}}
labels: ${{ steps.metadata.outputs.labels }}
push: true
file: ./python-flask-dev/Dockerfile
file: ./python-flask/Dockerfile
target: ${{matrix.flavour}}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ Base images and requirements definitions for development of funding service desi

## Python Flask Dev
Contains requirements files for different versions of a python flask app. The [Dockerfile](./python-flask-dev/Dockerfile) contains the following build targets:
- `flask`: Developer image based on python 3.10 bullseye, with Flask 3.0.3 installed on top, plus everything in [requirements-dev.txt](./python-flask-dev/requirements-dev.txt)
- `flask`: Developer image based on python 3.10 bullseye, with Flask 3.0.3 installed on top, plus everything in [requirements-dev.txt](./python-flask/requirements-dev.txt)
- `frontend`: Base on `flask` above, with everything from [requirements-frontend.txt](./python-flask-dev/requirements-frontend.txt) installed

## Workflows
- [Publish](/.github/workflows/publish.yml): Uses a matrix strategy to build each target in the Dockerfile and publish these to GHCR. If on `main`, will tag them as specified in [tags](./python-flask-dev/tags). (At present if you add something to tags you also need to add to [publish.yml](./.github/workflows/publish.yml)).

# Future Improvements
- Make the workflow just use all tags in the tags file, not hard code them?
- If we add other base images besides [python-flask-dev](./python-flask-dev/), make the workflow use a matrix approach so it builds all of these?
- If we add other base images besides [python-flask](./python-flask/), make the workflow use a matrix approach so it builds all of these?
- Are we using the right tag names?
- Stop using pip-compile and use rye?
Empty file.
3 changes: 0 additions & 3 deletions python-flask-dev/tags

This file was deleted.

10 changes: 5 additions & 5 deletions python-flask-dev/Dockerfile → python-flask/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ RUN pip install --upgrade pip && pip install -r requirements-frontend.txt


# --------------------------------------------------
# Will hold config for building DB base image
# Base image to build db images on - includes sql alchemy and connexion
# --------------------------------------------------

# FROM flask as db
# WORKDIR /app
# COPY requirements-db.txt requirements-db.txt
# RUN pip install --upgrade pip && pip install -r requirements-db.txt
FROM flask as db
WORKDIR /app
COPY requirements-db.txt requirements-db.txt
RUN pip install --upgrade pip && pip install -r requirements-db.txt
18 changes: 18 additions & 0 deletions python-flask/requirements-db.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#-----------------------------------
# Database
#-----------------------------------
SQLAlchemy[mypy]>=2.0.30
Flask-SQLAlchemy==3.1.1
Flask-Migrate==4.0.7
sqlalchemy-utils==0.41.2
sqlalchemy_json==0.7.0
psycopg2-binary==2.9.9
uvicorn==0.30.1
marshmallow-sqlalchemy==1.0.0
#-----------------------------------
# Connexion APIs
#-----------------------------------
connexion[flask,swagger-ui,uvicorn]
swagger-ui-bundle==1.1.0
openapi-spec-validator
prance
203 changes: 203 additions & 0 deletions python-flask/requirements-db.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile requirements-db.in
#
a2wsgi==1.10.6
# via connexion
alembic==1.13.2
# via flask-migrate
anyio==4.4.0
# via
# httpx
# starlette
# watchfiles
asgiref==3.8.1
# via
# connexion
# flask
attrs==23.2.0
# via
# jsonschema
# referencing
blinker==1.8.2
# via flask
certifi==2024.7.4
# via
# httpcore
# httpx
# requests
chardet==5.2.0
# via prance
charset-normalizer==3.3.2
# via requests
click==8.1.7
# via
# flask
# uvicorn
connexion[flask,swagger-ui,uvicorn]==3.1.0
# via -r requirements-db.in
exceptiongroup==1.2.1
# via anyio
flask[async]==3.0.3
# via
# connexion
# flask-migrate
# flask-sqlalchemy
flask-migrate==4.0.7
# via -r requirements-db.in
flask-sqlalchemy==3.1.1
# via
# -r requirements-db.in
# flask-migrate
h11==0.14.0
# via
# httpcore
# uvicorn
httpcore==1.0.5
# via httpx
httptools==0.6.1
# via uvicorn
httpx==0.27.0
# via connexion
idna==3.7
# via
# anyio
# httpx
# requests
inflection==0.5.1
# via connexion
itsdangerous==2.2.0
# via flask
jinja2==3.1.4
# via
# connexion
# flask
# swagger-ui-bundle
jsonschema==4.23.0
# via
# connexion
# openapi-schema-validator
# openapi-spec-validator
jsonschema-path==0.3.3
# via openapi-spec-validator
jsonschema-specifications==2023.12.1
# via
# jsonschema
# openapi-schema-validator
lazy-object-proxy==1.10.0
# via openapi-spec-validator
mako==1.3.5
# via alembic
markupsafe==2.1.5
# via
# jinja2
# mako
# werkzeug
marshmallow==3.21.3
# via marshmallow-sqlalchemy
marshmallow-sqlalchemy==1.0.0
# via -r requirements-db.in
mypy==1.10.1
# via sqlalchemy
mypy-extensions==1.0.0
# via mypy
openapi-schema-validator==0.6.2
# via openapi-spec-validator
openapi-spec-validator==0.7.1
# via -r requirements-db.in
packaging==24.1
# via
# marshmallow
# prance
pathable==0.4.3
# via jsonschema-path
prance==23.6.21.0
# via -r requirements-db.in
psycopg2-binary==2.9.9
# via -r requirements-db.in
python-dotenv==1.0.1
# via uvicorn
python-multipart==0.0.9
# via connexion
pyyaml==6.0.1
# via
# connexion
# jsonschema-path
# uvicorn
referencing==0.35.1
# via
# jsonschema
# jsonschema-path
# jsonschema-specifications
requests==2.32.3
# via
# connexion
# jsonschema-path
# prance
rfc3339-validator==0.1.4
# via openapi-schema-validator
rpds-py==0.19.0
# via
# jsonschema
# referencing
ruamel-yaml==0.18.6
# via prance
ruamel-yaml-clib==0.2.8
# via ruamel-yaml
six==1.16.0
# via
# prance
# rfc3339-validator
sniffio==1.3.1
# via
# anyio
# httpx
sqlalchemy[mypy]==2.0.31
# via
# -r requirements-db.in
# alembic
# flask-sqlalchemy
# marshmallow-sqlalchemy
# sqlalchemy
# sqlalchemy-json
# sqlalchemy-utils
sqlalchemy-json==0.7.0
# via -r requirements-db.in
sqlalchemy-utils==0.41.2
# via -r requirements-db.in
starlette==0.37.2
# via connexion
swagger-ui-bundle==1.1.0
# via
# -r requirements-db.in
# connexion
tomli==2.0.1
# via mypy
typing-extensions==4.12.2
# via
# a2wsgi
# alembic
# anyio
# asgiref
# connexion
# mypy
# sqlalchemy
# uvicorn
urllib3==2.2.2
# via requests
uvicorn[standard]==0.30.1
# via
# -r requirements-db.in
# connexion
uvloop==0.19.0
# via uvicorn
watchfiles==0.22.0
# via uvicorn
websockets==12.0
# via uvicorn
werkzeug==3.0.3
# via
# connexion
# flask
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
#-----------------------------------

pytest==8.2.2
pytest-mock==3.12.0
pytest-mock==3.14.0
pytest-html>=3.2.0
pytest-env==1.1.3

#-----------------------------------
# Dev Utils
#-----------------------------------
invoke==2.2.0
pre-commit==3.7.1

#-----------------------------------
# Code Quality
Expand All @@ -21,4 +23,4 @@ black==24.3.0
#-----------------------------------
# Other Dev Dependencies
#-----------------------------------
beautifulsoup4==4.12.2
beautifulsoup4==4.12.3
Loading
Loading