-
Notifications
You must be signed in to change notification settings - Fork 3
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 #94 from LandRegistry/docker
Docker support
- Loading branch information
Showing
13 changed files
with
152 additions
and
89 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
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 |
---|---|---|
@@ -1,38 +1,44 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a single version of Python | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | ||
|
||
name: Python application | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [main] | ||
branches: [ "main" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.8", "3.9", "3.10", "3.11"] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
- name: Set up Python 3.11 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
python-version: 3.11 | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install safety flake8 black bandit | ||
pip install -r requirements_dev.txt | ||
pip install -r requirements.txt | ||
- name: Check dependencies for known security vulnerabilities | ||
run: safety check -r requirements.txt | ||
- name: Check code for potential security vulnerabilities | ||
run: bandit -r . | ||
run: bandit -r . -x /tests | ||
- name: Check code formatting | ||
run: black . -l 120 --check | ||
run: | | ||
black . -t py311 -l 120 --check | ||
isort . -c | ||
- name: Lint with flake8 | ||
run: | | ||
# stop the build if there are Python syntax errors or undefined names | ||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | ||
# exit-zero treats all errors as warnings. | ||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=120 --statistics | ||
# - name: Test with pytest | ||
# run: python -m pytest --cov=app --cov-report=term-missing --cov-branch |
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,21 @@ | ||
FROM python:3.11-slim | ||
|
||
RUN useradd containeruser | ||
|
||
WORKDIR /home/containeruser | ||
|
||
COPY app app | ||
COPY govuk-frontend-flask.py config.py docker-entrypoint.sh requirements.txt ./ | ||
RUN pip install -r requirements.txt \ | ||
&& chmod +x docker-entrypoint.sh \ | ||
&& chown -R containeruser:containeruser ./ | ||
|
||
# Set environment variables | ||
ENV FLASK_APP=govuk-frontend-flask.py \ | ||
PYTHONDONTWRITEBYTECODE=1 \ | ||
PYTHONUNBUFFERED=1 | ||
|
||
USER containeruser | ||
|
||
EXPOSE 8000 | ||
ENTRYPOINT ["./docker-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
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,28 @@ | ||
services: | ||
web: | ||
container_name: govuk-frontend-flask | ||
build: . | ||
restart: always | ||
environment: | ||
- CONTACT_EMAIL=[contact email] | ||
- CONTACT_PHONE=[contact phone] | ||
- DEPARTMENT_NAME=[name of department] | ||
- DEPARTMENT_URL=[url of department] | ||
- REDIS_URL=redis://cache:6379 | ||
- SECRET_KEY=4f378500459bb58fecf903ea3c113069f11f150b33388f56fc89f7edce0e6a84 | ||
- SERVICE_NAME=[name of service] | ||
- SERVICE_PHASE=[phase] | ||
- SERVICE_URL=[url of service] | ||
ports: | ||
- "8000:8000" | ||
volumes: | ||
- .:/home/containeruser | ||
depends_on: | ||
- cache | ||
cache: | ||
container_name: redis | ||
image: redis:7.0-alpine | ||
restart: always | ||
ports: | ||
- 6379:6379 | ||
|
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,3 @@ | ||
#!/bin/bash | ||
openssl req -new -x509 -newkey rsa:4096 -nodes -out cert.pem -keyout key.pem -days 365 -subj "/C=GB/ST=Devon/L=Plymouth/O=HM Land Registry/OU=DDaT/CN=localhost" | ||
exec gunicorn --reload --certfile cert.pem --keyfile key.pem -b :8000 --access-logfile - --error-logfile - govuk-frontend-flask:app |
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,11 @@ | ||
cssmin | ||
email_validator | ||
flask | ||
flask-assets | ||
flask-compress | ||
flask-limiter | ||
flask-limiter[redis] | ||
flask-talisman | ||
flask | ||
govuk-frontend-jinja | ||
govuk-frontend-wtf | ||
gunicorn | ||
jsmin | ||
python-dotenv | ||
redis |
Oops, something went wrong.