enable translations; environment config; heavily expanded dockerfile; dev docker-compose
This commit is contained in:
parent
0fcf3a5dae
commit
4e9fd4abed
|
@ -6,9 +6,8 @@ ENV PYTHONDONTWRITEBYTECODE 1
|
|||
ENV PYTHONUNBUFFERED 1
|
||||
EXPOSE 8000
|
||||
|
||||
# psycopg2 dependencies
|
||||
RUN apk update \
|
||||
&& apk add postgresql-dev gcc python3-dev musl-dev
|
||||
&& apk add postgresql-dev gcc python3-dev musl-dev gettext postgresql-client
|
||||
|
||||
# install dependencies
|
||||
ADD ./requirements.txt .
|
||||
|
@ -20,4 +19,8 @@ RUN addgroup -S portier && adduser -S portier -G portier
|
|||
# add code
|
||||
ADD --chown=portier:portier . /app
|
||||
|
||||
RUN ./manage.py collectstatic --noinput --link
|
||||
RUN ./manage.py compilemessages
|
||||
USER portier
|
||||
|
||||
CMD ["/app/start.sh", "migrate_start"]
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
version: '2.4'
|
||||
|
||||
services:
|
||||
web:
|
||||
build: .
|
||||
ports:
|
||||
- 8000:8000
|
||||
depends_on:
|
||||
- postgres
|
||||
- redis
|
||||
environment:
|
||||
DEBUG: 1
|
||||
SECRET_KEY: "D4mn1t_Ch4nG3_M3!1!!"
|
||||
SQL_ENGINE: django.db.backends.postgresql
|
||||
SQL_USER: portier
|
||||
SQL_PASSWORD: portier
|
||||
SQL_DATABASE: portier
|
||||
SQL_HOST: postgres
|
||||
SQL_PORT: 5432
|
||||
REDIS_HOST: redis
|
||||
REDIS_PORT: 6379
|
||||
redis:
|
||||
image: redis:5-alpine
|
||||
postgres:
|
||||
image: postgres:11.7-alpine
|
||||
environment:
|
||||
POSTGRES_PASSWORD: "portier"
|
||||
POSTGRES_USER: "portier"
|
||||
POSTGRES_DB: "portier"
|
|
@ -0,0 +1,23 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-04-20 20:58+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
|
||||
#: srs/models.py:9
|
||||
msgid "srs_application_name"
|
||||
msgstr ""
|
|
@ -0,0 +1,23 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-04-20 20:58+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
|
||||
#: srs/models.py:9
|
||||
msgid "srs_application_name"
|
||||
msgstr ""
|
|
@ -20,12 +20,11 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|||
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = '-xcxbgd8w&w&nv0-e!5=kd%u5esjt07$h5*+$goica9nc$l!(9'
|
||||
SECRET_KEY = os.environ.get("SECRET_KEY", default="CHANGE_ME!")
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = ['*']
|
||||
DEBUG = int(os.environ.get("DEBUG", default=0))
|
||||
ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS", default="*").split(" ")
|
||||
|
||||
|
||||
# Application definition
|
||||
|
@ -76,9 +75,13 @@ WSGI_APPLICATION = 'portier.wsgi.application'
|
|||
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
||||
"default": {
|
||||
"ENGINE": os.environ.get("SQL_ENGINE", "django.db.backends.sqlite3"),
|
||||
"NAME": os.environ.get("SQL_DATABASE", os.path.join(BASE_DIR, "db.sqlite3")),
|
||||
"USER": os.environ.get("SQL_USER", "portier"),
|
||||
"PASSWORD": os.environ.get("SQL_PASSWORD", "portier"),
|
||||
"HOST": os.environ.get("SQL_HOST", "postgres"),
|
||||
"PORT": os.environ.get("SQL_PORT", "5432"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,10 +123,12 @@ USE_TZ = True
|
|||
# https://docs.djangoproject.com/en/3.0/howto/static-files/
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
|
||||
|
||||
|
||||
CELERY_BROKER_URL = 'redis://localhost:6379'
|
||||
CELERY_RESULT_BACKEND = 'redis://localhost:6379'
|
||||
# Celery
|
||||
CELERY_BROKER_URL = "redis://{}:{}".format(os.environ.get('REDIS_HOST', default='redis'), os.environ.get('REDIS_PORT', default=6379))
|
||||
CELERY_RESULT_BACKEND = "redis://{}:{}".format(os.environ.get('REDIS_HOST', default='redis'), os.environ.get('REDIS_PORT', default=6379))
|
||||
CELERY_ACCEPT_CONTENT = ['application/json']
|
||||
CELERY_RESULT_SERIALIZER = 'json'
|
||||
CELERY_TASK_SERIALIZER = 'json'
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
django>=3.0
|
||||
celery>=4.4
|
||||
gunicorn>=20
|
||||
psycopg2-binary
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
from django.db import models
|
||||
from django.utils.translation import gettext as _
|
||||
import uuid
|
||||
|
||||
from . import signals
|
||||
|
||||
|
||||
class Application(models.Model):
|
||||
name = models.CharField(max_length=100, unique=True)
|
||||
name = models.CharField(max_length=100, unique=True, help_text=_("srs_application_name"))
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
|
24
start.sh
24
start.sh
|
@ -5,15 +5,39 @@ migrate() {
|
|||
python manage.py migrate
|
||||
}
|
||||
|
||||
wait_for_redis() {
|
||||
echo "Trying to connect to redis at ${REDIS_HOST:-redis}:${REDIS_PORT:-6379} ..."
|
||||
while ! nc -z ${REDIS_HOST:-redis} ${REDIS_PORT:-6379};
|
||||
do
|
||||
sleep 1;
|
||||
done;
|
||||
echo "Successfully connected to redis. Continuing.";
|
||||
}
|
||||
|
||||
wait_for_database() {
|
||||
echo "Trying to connect to database at ${SQL_HOST:-postgres}:${SQL_PORT:-5432} ..."
|
||||
while ! nc -z ${SQL_HOST:-postgres} ${SQL_PORT:-5432};
|
||||
do
|
||||
sleep 1;
|
||||
done;
|
||||
echo "Successfully connected to database. Continuing.";
|
||||
}
|
||||
|
||||
case $1 in
|
||||
"create_superuser" )
|
||||
wait_for_redis
|
||||
wait_for_database
|
||||
python manage.py createsuperuser --no-input --username "${ADMIN_USER:-admin}" --email "${ADMIN_EMAIL:-post@chaoswest.tv}"
|
||||
;;
|
||||
"migrate_start" )
|
||||
wait_for_redis
|
||||
wait_for_database
|
||||
migrate
|
||||
gunicorn -w 4 --bind 0.0.0.0:${EXPOSE_PORT:-8000} portier.wsgi
|
||||
;;
|
||||
"only_start" )
|
||||
wait_for_redis
|
||||
wait_for_database
|
||||
gunicorn -w 4 --bind 0.0.0.0:${EXPOSE_PORT:-8000} portier.wsgi
|
||||
;;
|
||||
esac
|
||||
|
|
Loading…
Reference in New Issue