feat: environment file

This commit is contained in:
Gerard Gascón 2025-04-11 21:12:54 +02:00
parent af7b4125c9
commit 9b818be7c3
3 changed files with 8 additions and 4 deletions

View file

@ -2,11 +2,11 @@ services:
torreta:
build: .
environment:
DJANGO_SUPERUSER_PASSWORD: "admin"
DJANGO_SUPERUSER_PASSWORD: ${ADMIN_PASSWORD}
command: >
sh -c "python manage.py migrate &&
python manage.py collectstatic --no-input &&
python manage.py createsuperuser --username "admin" --email=admin@admin.com --noinput
python manage.py createsuperuser --username "${ADMIN_USER}" --email=admin@admin.com --noinput
python manage.py runserver 0.0.0.0:4555"
volumes:
- static:/app/staticfiles

View file

@ -2,3 +2,4 @@ asgiref==3.8.1
Django==5.1.7
sqlparse==0.5.3
tzdata==2025.2
python-dotenv==1.0.1

View file

@ -11,6 +11,9 @@ https://docs.djangoproject.com/en/5.1/ref/settings/
"""
import os
from pathlib import Path
from dotenv import load_dotenv
load_dotenv()
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
@ -20,7 +23,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-7o__%v#^c7@y8$rvma%s_z-jma7xj#5y-en@ll(_zmk3u=sob7'
SECRET_KEY = os.environ.get('SECRET_KEY')
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
@ -30,7 +33,7 @@ if DEBUG:
CSRF_TRUSTED_ORIGINS = ['http://localhost']
else:
ALLOWED_HOSTS = ['*']
CSRF_TRUSTED_ORIGINS = ['http://localhost']
CSRF_TRUSTED_ORIGINS = ['http://localhost', 'http://torreta.local', 'https://torreta.gerardgascon.com']
# Application definition