|
| 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. |
0 commit comments