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: torreta:
build: . build: .
environment: environment:
DJANGO_SUPERUSER_PASSWORD: "admin" DJANGO_SUPERUSER_PASSWORD: ${ADMIN_PASSWORD}
command: > command: >
sh -c "python manage.py migrate && sh -c "python manage.py migrate &&
python manage.py collectstatic --no-input && 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" python manage.py runserver 0.0.0.0:4555"
volumes: volumes:
- static:/app/staticfiles - static:/app/staticfiles

View file

@ -2,3 +2,4 @@ asgiref==3.8.1
Django==5.1.7 Django==5.1.7
sqlparse==0.5.3 sqlparse==0.5.3
tzdata==2025.2 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 import os
from pathlib import Path from pathlib import Path
from dotenv import load_dotenv
load_dotenv()
# Build paths inside the project like this: BASE_DIR / 'subdir'. # Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent 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/ # See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret! # 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! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False DEBUG = False
@ -30,7 +33,7 @@ if DEBUG:
CSRF_TRUSTED_ORIGINS = ['http://localhost'] CSRF_TRUSTED_ORIGINS = ['http://localhost']
else: else:
ALLOWED_HOSTS = ['*'] ALLOWED_HOSTS = ['*']
CSRF_TRUSTED_ORIGINS = ['http://localhost'] CSRF_TRUSTED_ORIGINS = ['http://localhost', 'http://torreta.local', 'https://torreta.gerardgascon.com']
# Application definition # Application definition