Skip to content

Commit 218c3a7

Browse files
committed
Initial commit
0 parents  commit 218c3a7

File tree

9 files changed

+1134
-0
lines changed

9 files changed

+1134
-0
lines changed

.env.example

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Database host
2+
DB_HOST=db
3+
4+
# Name of the database
5+
DB_NAME=bpc
6+
7+
# Username for the database
8+
DB_USER=bpc
9+
10+
# Password for the database
11+
DB_PASSWORD=bpc
12+
13+
# Database port
14+
DB_PORT=""
15+
16+
# Allowed hosts
17+
ALLOWED_HOSTS="*"
18+
19+
# Core script package version
20+
# Find the latest version here: https://github.com/OS2borgerPC/os2borgerpc-core-scripts/releases
21+
CORE_SCRIPT_VERSION_TAG=v0.1.4
22+
23+
# Matching commit hash for the core script package. (The commit that the tag points to)
24+
CORE_SCRIPT_COMMIT_HASH=db319672efdcc0f7402c4a7370aa763be9960c38
25+
26+
# URL for downloading BorgerPC ISO images
27+
PC_IMAGE_RELEASES_URL=https://github.com/OS2borgerPC/os2borgerpc-image/releases
28+
29+
# URL for downloading Kiosk ISO images
30+
KIOSK_IMAGE_RELEASES_URL=https://github.com/OS2borgerPC/os2borgerpc-kiosk-image/releases
31+
32+
# Enable debug mode
33+
DEBUG=True
34+
35+
# Secret key for Django
36+
SECRET_KEY=v3rys1kr3t
37+
38+
# Username for admin user
39+
ADMIN_USERNAME=admin
40+
41+
# Email for admin user
42+
ADMIN_EMAIL=[email protected]
43+
44+
# Password for admin user
45+
ADMIN_PASSWORD=admin
46+
47+
# Time zone
48+
TIME_ZONE=Europe/Copenhagen
49+
50+
# Language code
51+
LANGUAGE_CODE=da-dk
52+
53+
# Initialize the database
54+
INITIALIZE_DATABASE=True
55+
56+
# Log level
57+
LOG_LEVEL=INFO
58+
59+
# URL for Cicero server
60+
CICERO_URL=CICERO_SERVER_HERE
61+
62+
# Validator for citizen login API
63+
CITIZEN_LOGIN_API_VALIDATOR=system.utils.always_validate_citizen
64+
65+
# Username for PostgreSQL
66+
POSTGRES_USER=bpc
67+
68+
# Password for PostgreSQL
69+
POSTGRES_PASSWORD=bpc

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.env
2+
*.crt
3+
*.cer
4+
*.key

LICENSE

Lines changed: 607 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# OS2BorgerPC Admin Site Deployment
2+
3+
This is an experimental deployment setup for the OS2BorgerPC Admin Site. It can be used at your own risk.
4+
5+
## Usage
6+
7+
This setup is currently used in Sønderborg Kommune, where it is installed on a server that can only be accessed from the local network. There is no internet access to the server.
8+
9+
## Security Considerations
10+
11+
Security considerations for exposing this installation to the internet have not been made. If you plan to expose this setup to the internet, please ensure that you take appropriate security measures to protect the server and the application.
12+
13+
## Docker Compose Setup
14+
15+
The deployment uses Docker Compose to manage the services. Here is an overview of the services defined in the `docker-compose.yml` file:
16+
17+
### Services
18+
19+
- **os2borgerpc-admin**: This is the main service running the OS2BorgerPC Admin Site. It uses the image `ghcr.io/os2borgerpc/os2borgerpc-admin-site:7.0.0`. The service is configured to use environment variables from the `.env` file and mounts the `settings.py` file as read-only. It exposes ports `9999` and `8080`.
20+
21+
- **db**: This service runs a PostgreSQL database using the `postgres:latest` image. It is configured to always restart and uses environment variables from the `.env` file. The database data is persisted using the `postgres-data` volume.
22+
23+
- **nginx**: This service runs an Nginx proxy using the `nginx:latest` image. It is configured to handle SSL termination and proxy requests to the `os2borgerpc-admin` service. The Nginx configuration file (`nginx.conf`) and SSL certificates (`ssl` directory) are mounted as read-only. The service exposes ports `80` and `443`.
24+
25+
### Volumes
26+
27+
- **admin-media**: This volume is used to store media files for the `os2borgerpc-admin` service.
28+
- **postgres-data**: This volume is used to persist PostgreSQL database data.
29+
30+
### Proxy and SSL Certificates
31+
32+
The Nginx service acts as a reverse proxy for the `os2borgerpc-admin` service. It handles SSL termination and forwards requests to the appropriate backend service. The SSL certificates are stored in the `ssl` directory and are mounted into the Nginx container.
33+
34+
## Environment Variables
35+
36+
The following environment variables are used in this setup:
37+
38+
- `DB_HOST`: Database host
39+
- `DB_NAME`: Name of the database
40+
- `DB_USER`: Username for the database
41+
- `DB_PASSWORD`: Password for the database
42+
- `DB_PORT`: Database port
43+
- `ALLOWED_HOSTS`: Allowed hosts
44+
- `CORE_SCRIPT_VERSION_TAG`: Version of the global scripts
45+
- `CORE_SCRIPT_COMMIT_HASH`: Matching commit hash for the selected tagged version of the global scripts
46+
- `PC_IMAGE_RELEASES_URL`: URL for downloading BorgerPC ISO images
47+
- `KIOSK_IMAGE_RELEASES_URL`: URL for downloading Kiosk ISO images
48+
- `DEBUG`: Enable debug mode
49+
- `SECRET_KEY`: Secret key for Django
50+
- `ADMIN_USERNAME`: Username for admin user
51+
- `ADMIN_EMAIL`: Email for admin user
52+
- `ADMIN_PASSWORD`: Password for admin user
53+
- `TIME_ZONE`: Time zone
54+
- `LANGUAGE_CODE`: Language code
55+
- `INITIALIZE_DATABASE`: Initialize the database
56+
- `LOG_LEVEL`: Log level
57+
- `CICERO_URL`: URL for Cicero server
58+
- `CITIZEN_LOGIN_API_VALIDATOR`: Validator for citizen login API
59+
- `POSTGRES_USER`: Username for PostgreSQL
60+
- `POSTGRES_PASSWORD`: Password for PostgreSQL
61+
- `USE_X_FORWARDED_HOST`: Ensure that Django knows it's behind a proxy
62+
- `SECURE_PROXY_SSL_HEADER`: Secure proxy SSL header
63+
64+
## TODO
65+
66+
The entire Django `settings.py` fro os2borgerpc-admin-site is stored as a copy in this project and overwrites the `settings.py` in the image. This is done only to append two lines at the bottom:
67+
68+
```python
69+
# Ensure that Django knows it's behind a proxy
70+
USE_X_FORWARDED_HOST = True
71+
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
72+
73+
This is not a proper approach and should be handled differently. For example, by adding the lines to settings.py in the os2borgerpc-admin-site project.

compose.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
services:
2+
os2borgerpc-admin:
3+
image: ghcr.io/os2borgerpc/os2borgerpc-admin-site:7.0.0
4+
env_file:
5+
- .env
6+
volumes:
7+
- admin-media:/media
8+
- ./settings.py:/code/admin_site/os2borgerpc_admin/settings.py:ro
9+
depends_on:
10+
- db
11+
ports:
12+
- 9999:9999
13+
- 8080:8080
14+
stdin_open: true
15+
tty: true
16+
privileged: true
17+
db:
18+
image: postgres:latest
19+
restart: always
20+
env_file:
21+
- .env
22+
volumes:
23+
- postgres-data:/var/lib/postgresql/data
24+
nginx:
25+
image: nginx:latest
26+
ports:
27+
- 80:80
28+
- 443:443
29+
volumes:
30+
- ./nginx.conf:/etc/nginx/nginx.conf:ro
31+
- ./ssl:/etc/nginx/ssl:ro
32+
depends_on:
33+
- os2borgerpc-admin
34+
volumes:
35+
admin-media:
36+
postgres-data:

nginx.conf

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
events {
2+
worker_connections 1024;
3+
}
4+
5+
http {
6+
server {
7+
listen 80;
8+
server_name os2borgerpc-admin.sonderborg.dk;
9+
10+
location / {
11+
return 301 https://$host$request_uri;
12+
}
13+
}
14+
15+
server {
16+
listen 443 ssl;
17+
server_name os2borgerpc-admin.sonderborg.dk;
18+
19+
ssl_certificate /etc/nginx/ssl/nginx.crt;
20+
ssl_certificate_key /etc/nginx/ssl/nginx.key;
21+
22+
location / {
23+
proxy_pass http://os2borgerpc-admin:9999;
24+
proxy_set_header Host $host;
25+
proxy_set_header X-Real-IP $remote_addr;
26+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
27+
proxy_set_header X-Forwarded-Proto $scheme;
28+
}
29+
30+
}
31+
}

0 commit comments

Comments
 (0)