-
Notifications
You must be signed in to change notification settings - Fork 12
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 #206 from rcpch/dockerise
Dockerise
- Loading branch information
Showing
28 changed files
with
16,340 additions
and
744 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 |
---|---|---|
@@ -1,29 +1,38 @@ | ||
|
||
name: Run tests for all new pushes and PRs (when opened or edited) | ||
name: Run Pytest on pushes to main branches or PRs to any branch | ||
|
||
on: | ||
push: | ||
pull_request: | ||
types: [opened, edited] | ||
|
||
branches: | ||
- "*" | ||
push: | ||
branches: | ||
- development | ||
- staging | ||
- live | ||
|
||
jobs: | ||
run-pytest: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.9", "3.10", "3.11", "3.12"] | ||
|
||
steps: | ||
- uses: actions/checkout@master | ||
- uses: actions/checkout@v4 # latest as at February 2024 | ||
|
||
- name: Set up Python version | ||
uses: actions/setup-python@v1 | ||
- name: Set up Python version ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 # latest as at March 2024 | ||
with: | ||
python-version: "3.8.x" | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Display Python version | ||
run: python -c "import sys; print(sys.version)" | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements/test-requirements.txt | ||
pip install -r requirements/development-requirements.txt | ||
- name: Run pytest | ||
run: | | ||
pytest --no-header -vv | ||
pytest --no-header -vv |
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,69 @@ | ||
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy | ||
# More GitHub Actions for Azure: https://github.com/Azure/actions | ||
# More info on Python, GitHub Actions, and Azure App Service: https://aka.ms/python-webapps-actions | ||
|
||
name: Build and deploy Python app to Azure Web App - rcpch-dgc-server-staging | ||
|
||
on: | ||
push: | ||
branches: | ||
- staging | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 # latest as at March 2024 | ||
|
||
- name: Set up Python version | ||
uses: actions/setup-python@v5 # latest as at March 2024 | ||
with: | ||
python-version: '3.12' | ||
|
||
- name: Create and start virtual environment | ||
run: | | ||
python -m venv venv | ||
source venv/bin/activate | ||
- name: Install dependencies | ||
run: pip install -r requirements.txt | ||
|
||
# Optional: Add step to run tests here (PyTest, Django test suites, etc.) | ||
|
||
- name: Zip artifact for deployment | ||
run: zip release.zip ./* -r | ||
|
||
- name: Upload artifact for deployment jobs | ||
uses: actions/upload-artifact@v4 # latest as at March 2024 | ||
with: | ||
name: python-app | ||
path: | | ||
release.zip | ||
!venv/ | ||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
environment: | ||
name: 'Production' | ||
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} | ||
|
||
steps: | ||
- name: Download artifact from build job | ||
uses: actions/download-artifact@v4 # latest as at March 2024 | ||
with: | ||
name: python-app | ||
|
||
- name: Unzip artifact for deployment | ||
run: unzip release.zip | ||
|
||
|
||
- name: 'Deploy to Azure Web App' | ||
uses: azure/webapps-deploy@v3 # latest as at March 2024 | ||
id: deploy-to-webapp | ||
with: | ||
app-name: 'rcpch-dgc-server-staging' | ||
slot-name: 'Production' | ||
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_20EF65F771AA44219C3529732124EFCE }} |
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 |
---|---|---|
@@ -1,13 +1,15 @@ | ||
FROM python:3.8-buster | ||
FROM python:3.12-bookworm | ||
|
||
RUN apt-get update -y | ||
COPY requirements/common-requirements.txt . | ||
|
||
WORKDIR /app | ||
COPY requirements/development-requirements.txt . | ||
|
||
COPY . /app | ||
RUN pip install -r development-requirements.txt | ||
|
||
EXPOSE 8000 | ||
|
||
RUN pip install -r requirements.txt | ||
WORKDIR /app | ||
|
||
COPY . /app | ||
|
||
CMD [ "uvicorn" "main:app" "--reload" ] | ||
CMD ["uvicorn", "main:app", "--reload", "--host", "0.0.0.0", "--port", "8000"] |
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 @@ | ||
# NOTE The below is the Docker Compose specification version NOT the Python version: | ||
version: "3.8" | ||
|
||
services: | ||
growth-api: | ||
build: . | ||
volumes: | ||
- .:/app | ||
ports: | ||
- "8000:8000" |
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
Oops, something went wrong.