Skip to content

Commit

Permalink
Added config for data dir in prod
Browse files Browse the repository at this point in the history
- Added contents dir root setting in config.toml
- Added STATIC_ROOT
  • Loading branch information
AmauryCarrade committed Apr 7, 2021
1 parent d91e750 commit e6398c6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
5 changes: 5 additions & 0 deletions config.example.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
secret_key = ""
allowed_hosts = [
"hawk.carrade.eu"
]

contents_dir = "/home/hawk/data"

[databases.default]
host = ""
Expand Down
4 changes: 2 additions & 2 deletions hawk/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/

STATICFILES_DIRS = [os.path.join(BASE_DIR, "static", "dist")]
STATICFILES_DIRS = [BASE_DIR / "static" / "dist"]
STATIC_URL = "/static/"

MEDIA_ROOT = os.path.join(BASE_DIR, "user-generated-content")
MEDIA_ROOT = BASE_DIR / "user-generated-content"
MEDIA_URL = "user-generated-content/"

MAINTENANCE_MODE_STATE_FILE_PATH = "maintenance"
Expand Down
10 changes: 7 additions & 3 deletions hawk/settings/prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
config = {}

DEBUG = False
ALLOWED_HOSTS = [
'hawk.carrade.eu'
]

ALLOWED_HOSTS = config.get("allowed_hosts", ['hawk.carrade.eu'])
SECRET_KEY = config["secret_key"]

CONTENTS_DIR = config.get("contents_dir", BASE_DIR / ".." / "hawk-data")

DATABASES = {
"default": {
"ENGINE": "django.db.backends.mysql",
Expand All @@ -38,3 +38,7 @@
# mysqlclient), but it's a pain to install on CentOS.
pymysql.version_info = (2, 0, 3, "final", 0)
pymysql.install_as_MySQLdb()

STATIC_ROOT = CONTENTS_DIR / "static"
MEDIA_ROOT = CONTENTS_DIR / "user-generated-content"
MAINTENANCE_MODE_STATE_FILE_PATH = CONTENTS_DIR / "maintenance"
2 changes: 1 addition & 1 deletion static/scss/bulma

0 comments on commit e6398c6

Please sign in to comment.