Skip to content

Commit d3bb948

Browse files
committed
Add inital django setup and README
1 parent c5c3a0a commit d3bb948

File tree

16 files changed

+353
-105
lines changed

16 files changed

+353
-105
lines changed

.env.example

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
DEBUG=True
2+
SECRET_KEY=somesercetkey
3+
DATABASE_URL=
4+
ALLOWED_HOSTS=localhost,127.0.0.1
5+
6+
POSTGRES_HOST=db
7+
POSTGRES_DB=lung_cancer_screening
8+
POSTGRES_USER=lung_cancer_screening
9+
POSTGRES_PASSWORD=password

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@
1111
!project.code-workspace
1212

1313
# Please, add your custom content below!
14+
15+
.env

.tool-versions

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# This file is for you! Please, updated to the versions agreed by your team.
22

33
terraform 1.7.0
4-
pre-commit 3.6.0
4+
pre-commit 3.13.2
55
vale 3.6.0
6-
gitleaks 8.18.4
6+
# gitleaks 8.18.4
77

88
# ==============================================================================
99
# The section below is reserved for Docker image versions.

Dockerfile

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
FROM python:3.12-alpine3.19 AS builder
2+
3+
ENV PYTHONDONTWRITEBYTECODE=1 \
4+
PYTHONUNBUFFERED=1 \
5+
PIP_NO_CACHE_DIR=1 \
6+
PIP_DISABLE_PIP_VERSION_CHECK=1
7+
8+
RUN apk add --no-cache \
9+
build-base \
10+
postgresql-dev \
11+
gcc \
12+
musl-dev \
13+
linux-headers
14+
15+
RUN python -m venv /opt/venv
16+
ENV PATH="/opt/venv/bin:$PATH"
17+
18+
COPY requirements.txt .
19+
COPY lung_cancer_screening ./lung_cancer_screening
20+
RUN pip install --no-cache-dir -r requirements.txt
21+
22+
23+
FROM python:3.12-alpine3.19
24+
25+
ENV PYTHONDONTWRITEBYTECODE=1 \
26+
PYTHONUNBUFFERED=1 \
27+
PATH="/opt/venv/bin:$PATH"
28+
29+
RUN apk add --no-cache \
30+
postgresql-libs \
31+
curl
32+
33+
RUN addgroup -g 1000 app && adduser -D -s /bin/sh -u 1000 -G app app
34+
35+
COPY --from=builder /opt/venv /opt/venv
36+
37+
RUN mkdir -p /app && chown -R app:app /app
38+
39+
WORKDIR /app
40+
41+
COPY --chown=app:app . .
42+
43+
USER app
44+
45+
EXPOSE 8000
46+
47+
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# the project as automated steps to be executed on locally and in the CD pipeline.
33

44
include scripts/init.mk
5+
include makefiles/dev.mk
56

67
# ==============================================================================
78

README.md

Lines changed: 20 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,54 @@
1-
# Repository Template
1+
# Lung Cancer Screening
22

3-
[![CI/CD Pull Request](https://github.com/nhs-england-tools/repository-template/actions/workflows/cicd-1-pull-request.yaml/badge.svg)](https://github.com/nhs-england-tools/repository-template/actions/workflows/cicd-1-pull-request.yaml)
4-
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=repository-template&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=repository-template)
5-
6-
Start with an overview or a brief description of what the project is about and what it does. For example -
7-
8-
Welcome to our repository template designed to streamline your project setup! This robust template provides a reliable starting point for your new projects, covering an essential tech stack and encouraging best practices in documenting.
9-
10-
This repository template aims to foster a user-friendly development environment by ensuring that every included file is concise and adequately self-documented. By adhering to this standard, we can promote increased clarity and maintainability throughout your project's lifecycle. Bundled within this template are resources that pave the way for seamless repository creation. Currently supported technologies are:
11-
12-
- Terraform
13-
- Docker
14-
15-
Make use of this repository template to expedite your project setup and enhance your productivity right from the get-go. Enjoy the advantage of having a well-structured, self-documented project that reduces overhead and increases focus on what truly matters - coding!
3+
This service is a digital version Lung Cancer Screening questionnaire and risk calculator.
164

175
## Table of Contents
186

19-
- [Repository Template](#repository-template)
7+
- [Lung Cancer Screening](#lung-cancer-screening)
208
- [Table of Contents](#table-of-contents)
9+
- [Prerequisites](#prerequisites)
2110
- [Setup](#setup)
22-
- [Prerequisites](#prerequisites)
23-
- [Configuration](#configuration)
24-
- [Usage](#usage)
25-
- [Testing](#testing)
26-
- [Design](#design)
27-
- [Diagrams](#diagrams)
28-
- [Modularity](#modularity)
11+
- [Running the app locally](#running-the-app-locally)
12+
- [Testing](#testing)
2913
- [Contributing](#contributing)
30-
- [Contacts](#contacts)
3114
- [Licence](#licence)
3215

33-
## Setup
34-
35-
By including preferably a one-liner or if necessary a set of clear CLI instructions we improve user experience. This should be a frictionless installation process that works on various operating systems (macOS, Linux, Windows WSL) and handles all the dependencies.
36-
37-
Clone the repository
38-
39-
```shell
40-
git clone https://github.com/nhs-england-tools/repository-template.git
41-
cd nhs-england-tools/repository-template
42-
```
43-
44-
### Prerequisites
16+
## Prerequisites
4517

4618
The following software packages, or their equivalents, are expected to be installed and configured:
4719

4820
- [Docker](https://www.docker.com/) container runtime or a compatible tool, e.g. [Podman](https://podman.io/),
49-
- [asdf](https://asdf-vm.com/) version manager,
50-
- [GNU make](https://www.gnu.org/software/make/) 3.82 or later,
51-
52-
> [!NOTE]<br>
53-
> The version of GNU make available by default on macOS is earlier than 3.82. You will need to upgrade it or certain `make` tasks will fail. On macOS, you will need [Homebrew](https://brew.sh/) installed, then to install `make`, like so:
54-
>
55-
> ```shell
56-
> brew install make
57-
> ```
58-
>
59-
> You will then see instructions to fix your [`$PATH`](https://github.com/nhs-england-tools/dotfiles/blob/main/dot_path.tmpl) variable to make the newly installed version available. If you are using [dotfiles](https://github.com/nhs-england-tools/dotfiles), this is all done for you.
60-
61-
- [GNU sed](https://www.gnu.org/software/sed/) and [GNU grep](https://www.gnu.org/software/grep/) are required for the scripted command-line output processing,
62-
- [GNU coreutils](https://www.gnu.org/software/coreutils/) and [GNU binutils](https://www.gnu.org/software/binutils/) may be required to build dependencies like Python, which may need to be compiled during installation,
63-
64-
> [!NOTE]<br>
65-
> For macOS users, installation of the GNU toolchain has been scripted and automated as part of the `dotfiles` project. Please see this [script](https://github.com/nhs-england-tools/dotfiles/blob/main/assets/20-install-base-packages.macos.sh) for details.
21+
- [GNU make](https://www.gnu.org/software/make/) 3.82 or later
6622

67-
- [Python](https://www.python.org/) required to run Git hooks,
68-
- [`jq`](https://jqlang.github.io/jq/) a lightweight and flexible command-line JSON processor.
69-
70-
### Configuration
23+
## Setup
7124

72-
Installation and configuration of the toolchain dependencies
25+
To setup the pre commit hooks run
7326

7427
```shell
7528
make config
7629
```
7730

78-
## Usage
79-
80-
After a successful installation, provide an informative example of how this project can be used. Additional code snippets, screenshots and demos work well in this space. You may also link to the other documentation resources, e.g. the [User Guide](./docs/user-guide.md) to demonstrate more use cases and to show more features.
81-
82-
### Testing
83-
84-
There are `make` tasks for you to configure to run your tests. Run `make test` to see how they work. You should be able to use the same entry points for local development as in your CI pipeline.
85-
86-
## Design
87-
88-
### Diagrams
31+
## Running the app locally
8932

90-
The [C4 model](https://c4model.com/) is a simple and intuitive way to create software architecture diagrams that are clear, consistent, scalable and most importantly collaborative. This should result in documenting all the system interfaces, external dependencies and integration points.
33+
The project runs locally inside docker. Please ensure you have docker installed.
9134

92-
![Repository Template](./docs/diagrams/Repository_Template_GitHub_Generic.png)
35+
You can run the application by running:
9336

94-
The source for diagrams should be in Git for change control and review purposes. Recommendations are [draw.io](https://app.diagrams.net/) (example above in [docs](.docs/diagrams/) folder) and [Mermaids](https://github.com/mermaid-js/mermaid). Here is an example Mermaids sequence diagram:
95-
96-
```mermaid
97-
sequenceDiagram
98-
User->>+Service: GET /users?params=...
99-
Service->>Service: auth request
100-
Service->>Database: get all users
101-
Database-->>Service: list of users
102-
Service->>Service: filter users
103-
Service-->>-User: list[User]
37+
```shell
38+
make dev-run
10439
```
10540

106-
### Modularity
41+
## Testing
10742

108-
Most of the projects are built with customisability and extendability in mind. At a minimum, this can be achieved by implementing service level configuration options and settings. The intention of this section is to show how this can be used. If the system processes data, you could mention here for example how the input is prepared for testing - anonymised, synthetic or live data.
43+
There are `make` tasks for you to configure to run your tests. Run `make test` to see how they work. You should be able to use the same entry points for local development as in your CI pipeline.
10944

11045
## Contributing
11146

112-
Describe or link templates on how to raise an issue, feature request or make a contribution to the codebase. Reference the other documentation files, like
113-
114-
- Environment setup for contribution, i.e. `CONTRIBUTING.md`
115-
- Coding standards, branching, linting, practices for development and testing
116-
- Release process, versioning, changelog
117-
- Backlog, board, roadmap, ways of working
118-
- High-level requirements, guiding principles, decision records, etc.
119-
120-
## Contacts
121-
122-
Provide a way to contact the owners of this project. It can be a team, an individual or information on the means of getting in touch via active communication channels, e.g. opening a GitHub discussion, raising an issue, etc.
47+
- Make sure you have pre-commit running so that pre-commit hooks run automatically when you commit - this should have been set up automatically when you ran `make config`.
48+
- Consider switching on format-on-save in your editor (e.g. [Black](https://github.com/psf/black) for Python)
12349

12450
## Licence
12551

126-
> The [LICENCE.md](./LICENCE.md) file will need to be updated with the correct year and owner
127-
128-
Unless stated otherwise, the codebase is released under the MIT License. This covers both the codebase and any sample code in the documentation.
52+
Unless stated otherwise, the codebase is released under the MIT License. This covers both the codebase and any sample code in the documentation. See [LICENCE.md](./LICENCE.md).
12953

13054
Any HTML or Markdown documentation is [© Crown Copyright](https://www.nationalarchives.gov.uk/information-management/re-using-public-sector-information/uk-government-licensing-framework/crown-copyright/) and available under the terms of the [Open Government Licence v3.0](https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/).

docker-compose.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
3+
services:
4+
web:
5+
build: .
6+
ports:
7+
- "8000:8000"
8+
env_file:
9+
- .env
10+
depends_on:
11+
- db
12+
volumes:
13+
- ./lung_cancer_screening:/app/lung_cancer_screening
14+
restart: unless-stopped
15+
16+
db:
17+
image: postgres:15-alpine
18+
env_file:
19+
- .env
20+
volumes:
21+
- postgres_data:/var/lib/postgresql/data
22+
ports:
23+
- "5432:5432"
24+
restart: unless-stopped
25+
healthcheck:
26+
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER}"]
27+
interval: 10s
28+
timeout: 5s
29+
retries: 5
30+
31+
volumes:
32+
postgres_data:
33+
redis_data:

lung_cancer_screening/__init__.py

Whitespace-only changes.

lung_cancer_screening/asgi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
ASGI config for lung_cancer_screening project.
3+
4+
It exposes the ASGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/5.2/howto/deployment/asgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.asgi import get_asgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'lung_cancer_screening.settings')
15+
16+
application = get_asgi_application()

0 commit comments

Comments
 (0)