Config env

This commit is contained in:
2026-05-04 12:22:15 +00:00
parent 1391a5ea3b
commit 9951719b26
4 changed files with 27 additions and 23 deletions

2
.gitignore vendored
View File

@@ -1,3 +1,5 @@
db.sqlite3 db.sqlite3
venv/* venv/*
media/* media/*
*.pyc
__pycache__/

4
Jenkinsfile vendored
View File

@@ -22,8 +22,8 @@ pipeline
when { branch 'main' } when { branch 'main' }
steps { steps {
sh ''' sh '''
cd /jenkins_test/sirh cd /var/www/sirh
echo $SUDO_PASSWORD | sudo -S chown -R jenkins:jenkins /jenkins_test/sirh echo $SUDO_PASSWORD | sudo -S chown -R jenkins:jenkins /var/www/sirh
git pull origin main git pull origin main
python3 -m venv venv python3 -m venv venv
. venv/bin/activate . venv/bin/activate

View File

@@ -12,21 +12,21 @@ https://docs.djangoproject.com/en/5.2/ref/settings/
import os import os
from pathlib import Path from pathlib import Path
from decouple import config
# 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
# Quick-start development settings - unsuitable for production # Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/5.2/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/5.2/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--wdb9t(77rvyac$_q!n5gw86&0r(0&&j171v9h!-_$jahsza*5' SECRET_KEY = config('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 = config('DEBUG', default=False, cast=bool)
ALLOWED_HOSTS = ["https://support.cerfig.org", "support.cerfig.org"] ALLOWED_HOSTS = config('ALLOWED_HOSTS', default=[]).split(',')
# Application definition # Application definition
@@ -79,24 +79,25 @@ WSGI_APPLICATION = 'SIRH.wsgi.application'
# Database # Database
# https://docs.djangoproject.com/en/5.2/ref/settings/#databases # https://docs.djangoproject.com/en/5.2/ref/settings/#databases
# DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.mysql',
# 'NAME': 'sirh',
# 'USER': 'sirh',
# 'PASSWORD': 'sirh-cerfig',
# 'HOST': 'localhost',
# 'PORT': '3306',
# }
# }
DATABASES = { if config('ENVIRONMENT') == 'local':
'default': { DATABASES = {
'ENGINE': 'django.db.backends.sqlite3', 'default': {
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
else:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': config('DATABASE_NAME'),
'USER': config('DATABASE_USER'),
'PASSWORD': config('DATABASE_PASSWORD'),
'HOST': config('DATABASE_HOST'),
'PORT': config('DATABASE_PORT'),
}
} }
}
# Password validation # Password validation
# https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators # https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators

View File

@@ -17,3 +17,4 @@ sqlparse==0.5.5
typing_extensions==4.15.0 typing_extensions==4.15.0
tzdata==2026.2 tzdata==2026.2
urllib3==2.6.3 urllib3==2.6.3
python-decouple