[FEAT] Isolate settings from image build and allow PWA customisation

Settings can now be changed without rebuilding the image
PWA settings can now be changed
This commit is contained in:
2023-02-10 13:32:13 +00:00
parent 905613d8e9
commit 555aae5d1c
14 changed files with 199 additions and 204 deletions

4
deploy/Vagrantfile vendored
View File

@@ -21,9 +21,7 @@ Vagrant.configure("2") do |config|
ansible.playbook = "playbook.yml"
ansible.host_vars = {
"default" => {
"deploy_environment" => "vagrant",
"django_debug" => 1,
"django_secret_key" => "debug_only_g62WlORMbo8iAcV7vKCKBQ=="
"deploy_environment" => "vagrant"
}
}
end

130
deploy/example.env Normal file
View File

@@ -0,0 +1,130 @@
# REQUIRED=Secret key
# Used to generate CSRF tokens - must never be made public
SECRET_KEY=changeme
# Debug
# Should the server run in debug mode? Provides information to users which is unsafe in production
# Default: False
DEBUG=False
# Project long name
# The project's full name.
# Default: Project Network Mapper
# PROJECT_LONG_NAME=Project Network Mapper
# Project short name
# The project's short/abbreviated name. This will also be used as the app's name when installed as PWA.
# Default: Network Mapper
# PROJECT_SHORT_NAME=Network Mapper
# Project description
# The project's description. Used when installed as a PWA.
# Default: Application to map network relationships in the organisation.
# PROJECT_DESCRIPTION=Application to map network relationships in the organisation.
# Theme color
# The project's theme color, in hex format (excluding the leading #).
# Default: 212121
# THEME_COLOR=212121
# Background color
# The project's background color, in hex format (excluding the leading #).
# Default: ffffff
# BACKGROUND_COLOR=ffffff
# Allowed hosts
# Accepted values for server header in request - protects against CSRF and CSS attacks
# Default: * if DEBUG else localhost
# ALLOWED_HOSTS=127.0.0.1,localhost,localhost.localdomain
# Site URL
# The URL the site will be deployed on. Do not include http://, https://, or a trailing slash.
# Default: localhost
# SITE_URL=localhost
# Site protocol
# The protocol the site uses. Valid options are http or https.
# Default: http
# SITE_PROTOCOL=http
# Trusted origins
# The trusted origin domains of requests - protects against CSRF and CSS attacks
# Default: '*' if DEBUG else 'http://127.0.0.1,http://localhost,http://localhost.localdomain'
# TRUSTED_ORIGINS=http://127.0.0.1,http://localhost,http://localhost.localdomain
# Database backup storage location
# Directory where database backups should be stored
# Default: .dbbackup
# DBBACKUP_STORAGE_LOCATION=.dbbackup
# Default language
# Default language - used for translation - has not been enabled
# Default: en-gb
# LANGUAGE_CODE=en-gb
# Timezone
# Default timezone
# Default: UTC
# TIME_ZONE=UTC
# Logging level
# Level of messages written to log file
# Default: INFO
# LOG_LEVEL=INFO
# Logging filename
# Path to logfile
# Default: debug.log
# LOG_FILENAME=debug.log
# Logging duration
# Number of days of logs to keep - logfile is rotated out at the end of each day
# Default: 14
# LOG_DAYS=14
# STMP host
# Hostname of SMTP server
# Default: None
# EMAIL_HOST=None
# Default from email address
# Email address from which messages are sent
# Default: None
# DEFAULT_FROM_EMAIL=None
# [DEBUG ONLY] Email file path
# Directory where emails will be stored if not using an SMTP server
# Default: mail.log
# EMAIL_FILE_PATH=mail.log
# SMTP username
# Username to authenticate with SMTP server
# Default: None
# EMAIL_HOST_USER=None
# SMTP password
# Password to authenticate with SMTP server
# Default: None
# EMAIL_HOST_PASSWORD=None
# SMTP port
# Port to access on SMTP server
# Default: 25
# EMAIL_PORT=25
# SMTP use TLS
# Use TLS to communicate with SMTP server? Usually on port 587
# Cannot be enabled at the same time as EMAIL_USE_SSL
# Default: True if EMAIL_PORT == 587 else False
# EMAIL_USE_TLS=True if EMAIL_PORT == 587 else False
# SMTP use SSL
# Use SSL to communicate with SMTP server? Usually on port 465
# Cannot be enabled at the same time as EMAIL_USE_TLS
# Default: True if EMAIL_PORT == 465 else False
# EMAIL_USE_SSL=True if EMAIL_PORT == 465 else False
# Google Maps API key
# Google Maps API key to display maps of people's locations
# Default: None
# GOOGLE_MAPS_API_KEY=None

View File

@@ -1,5 +1,4 @@
all:
hosts:
example.com:
django_debug: 0
django_secret_key: debug_only_g62WlORMbo8iAcV7vKCKBQ==

View File

@@ -61,8 +61,14 @@
- name: Copy settings file
ansible.builtin.copy:
src: 'settings.ini'
dest: '{{ project_src_dir }}/breccia_mapper/settings.ini'
src: '.env'
dest: '{{ project_dir }}/.env'
mode: 0600
- name: Copy site icon
ansible.builtin.copy:
src: 'icon-192x192.png'
dest: '{{ project_dir }}/icon-192x192.png'
mode: 0600
- name: Create database file
@@ -104,5 +110,5 @@
- name: Display warning about new superuser
debug:
msg:
- "[WARNING] A superuser has been provisioned with the username \"{{ superuser_username }}\" and password that was provided. This user has unlimited access to the network mapper."
- "[WARNING] A superuser has been provisioned with the username \"{{ superuser_username }}\" and the password that was provided. This user has unlimited access to the network mapper."
when: provision_superuser

View File

@@ -1,112 +0,0 @@
[settings]
; REQUIRED=Secret key
; Used to generate CSRF tokens - must never be made public
SECRET_KEY=changeme
; Debug
; Should the server run in debug mode? Provides information to users which is unsafe in production
; Default: False
DEBUG=False
; Allowed hosts
; Accepted values for server header in request - protects against CSRF and CSS attacks
; Default: * if DEBUG else localhost
# ALLOWED_HOSTS=127.0.0.1,localhost,localhost.localdomain
; Site URL
; The URL the site will be deployed on. Do not include http://, https://, or a trailing slash.
; Default: localhost
# SITE_URL=localhost
; Site protocol
; The protocol the site uses. Valid options are http or https.
; Default: http
# SITE_PROTOCOL=http
; Trusted origins
; The trusted origin domains of requests - protects against CSRF and CSS attacks
; Default: '*' if DEBUG else 'http://127.0.0.1,http://localhost,http://localhost.localdomain'
# TRUSTED_ORIGINS=http://127.0.0.1,http://localhost,http://localhost.localdomain
; Database URL
; URL to database - uses format described at https://github.com/jacobian/dj-database-url
; Default: sqlite://db.sqlite3
# DATABASE_URL=sqlite://db.sqlite3
; Database backup storage location
; Directory where database backups should be stored
; Default: .dbbackup
# DBBACKUP_STORAGE_LOCATION=.dbbackup
; Default language
; Default language - used for translation - has not been enabled
; Default: en-gb
# LANGUAGE_CODE=en-gb
; Timezone
; Default timezone
; Default: UTC
# TIME_ZONE=UTC
; Logging level
; Level of messages written to log file
; Default: INFO
# LOG_LEVEL=INFO
; Logging filename
; Path to logfile
; Default: debug.log
# LOG_FILENAME=debug.log
; Logging duration
; Number of days of logs to keep - logfile is rotated out at the end of each day
; Default: 14
# LOG_DAYS=14
; STMP host
; Hostname of SMTP server
; Default: None
# EMAIL_HOST=None
; Default from email address
; Email address from which messages are sent
; Default: None
# DEFAULT_FROM_EMAIL=None
; [DEBUG ONLY] Email file path
; Directory where emails will be stored if not using an SMTP server
; Default: mail.log
# EMAIL_FILE_PATH=mail.log
; SMTP username
; Username to authenticate with SMTP server
; Default: None
# EMAIL_HOST_USER=None
; SMTP password
; Password to authenticate with SMTP server
; Default: None
# EMAIL_HOST_PASSWORD=None
; SMTP port
; Port to access on SMTP server
; Default: 25
# EMAIL_PORT=25
; SMTP use TLS
; Use TLS to communicate with SMTP server? Usually on port 587
; Cannot be enabled at the same time as EMAIL_USE_SSL
; Default: True if EMAIL_PORT == 587 else False
# EMAIL_USE_TLS=True if EMAIL_PORT == 587 else False
; SMTP use SSL
; Use SSL to communicate with SMTP server? Usually on port 465
; Cannot be enabled at the same time as EMAIL_USE_TLS
; Default: True if EMAIL_PORT == 465 else False
# EMAIL_USE_SSL=True if EMAIL_PORT == 465 else False
; Google Maps API key
; Google Maps API key to display maps of people's locations
; Default: None
# GOOGLE_MAPS_API_KEY=None

View File

@@ -8,13 +8,14 @@ services:
ports:
- 8000:8000
environment:
DEBUG: {{ django_debug }}
DATABASE_URL: sqlite:////app/db.sqlite3
SECRET_KEY: {{ django_secret_key }}
DJANGO_DEBUG: ${DEBUG}
env_file:
- .env
volumes:
- {{ project_dir }}/db.sqlite3:/app/db.sqlite3:z
- static_files:/app/static
- media_files:/app/media
- {{ project_dir }}/icon-192x192.png:/app/media/icon-192x192.png:ro
caddy:
image: caddy:2