functioning container build

This commit is contained in:
meeb
2020-12-13 16:13:30 +11:00
parent 4117bb4446
commit 902bb1f26f
14 changed files with 242 additions and 83 deletions

View File

@@ -1,17 +0,0 @@
#!/bin/bash
set -x
# Compile SCSS files
/usr/bin/python3 /app/manage.py compilescss
# Collect the static files
/usr/bin/python3 /app/manage.py collectstatic --no-input --link
# Run migrations
/usr/bin/python3 /app/manage.py migrate
# Run what's in CMD
exec "$@"
# eof

View File

@@ -3,9 +3,11 @@ import multiprocessing
def get_num_workers():
# Sane max workers to allow to be spawned
cpu_workers = multiprocessing.cpu_count() * 2 + 1
# But default to 3
try:
num_workers = int(os.getenv('GUNICORN_WORKERS', 2))
num_workers = int(os.getenv('GUNICORN_WORKERS', 3))
except ValueError:
num_workers = cpu_workers
if 0 > num_workers > cpu_workers:
@@ -14,7 +16,7 @@ def get_num_workers():
def get_bind():
host = os.getenv('LISTEN_HOST', '0.0.0.0')
host = os.getenv('LISTEN_HOST', '127.0.0.1')
port = os.getenv('LISTEN_PORT', '8080')
return '{}:{}'.format(host, port)
@@ -23,11 +25,11 @@ workers = get_num_workers()
timeout = 30
chdir = '/app'
daemon = False
pidfile = '/run/www/gunicorn.pid'
user = 'www'
group = 'www'
pidfile = '/run/app/gunicorn.pid'
user = 'app'
group = 'app'
loglevel = 'info'
errorlog = '-'
accesslog = '-'
accesslog = '/dev/null' # Access logs are printed to stdout from nginx
django_settings = 'django.settings'
bind = get_bind()

View File

@@ -1,6 +1,6 @@
import os
from pathlib import Path
from
from binascii import hexlify
BASE_DIR = Path(__file__).resolve().parent.parent
@@ -9,20 +9,20 @@ ROOT_DIR = Path('/')
RANDOM_SECRET = hexlify(os.urandom(32)).decode()
SECRET_KEY = str(os.getenv('DJANGO_SECRET_KEY', RANDOM_SECRET))
ALLOWED_HOSTS_STR = str(os.getenv('TUBESYNC_HOSTS', 'localhost'))
ALLOWED_HOSTS_STR = str(os.getenv('TUBESYNC_HOSTS', '127.0.0.1,localhost'))
ALLOWED_HOSTS = ALLOWED_HOSTS_STR.split(',')
TIME_ZONE = os.getenv('TZ', 'UTC')
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': '/config/db.sqlite3',
'NAME': ROOT_DIR / 'config' / 'db.sqlite3',
}
}
BACKGROUND_TASK_ASYNC_THREADS = int(os.get('TUBESYNC_WORKERS', 2))
MEDIA_ROOT = ROOT_DIR / 'config' / 'media'
DOWNLOAD_ROOT = ROOT_DIR / 'downloads'

View File

@@ -0,0 +1,19 @@
from pathlib import Path
BASE_DIR = Path(__file__).resolve().parent.parent
SECRET_KEY = 'example-secret-key'
DEBUG = False
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
DOWNLOAD_ROOT = BASE_DIR / 'downloads'