make some changes to environment variable handling

This commit is contained in:
stupidcomputer 2024-06-28 16:00:59 -05:00
parent 1471dab714
commit f415713bdb
4 changed files with 12 additions and 7 deletions

View File

@ -1,2 +1,2 @@
SECRET_KEY=change_me SECRET_KEY=834701
DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1] DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1]

5
Makefile Normal file
View File

@ -0,0 +1,5 @@
prod: # execute this target on the production server in the nix-shell
rm -r franklincce/staticfiles
cd franklincce; python3 manage.py collectstatic
sed -i "s/change_me/$(shell shuf -i1-1000000 -n1)/g" .env.prod
docker-compose -f docker-compose.prod.yml up -d --build

View File

@ -19,14 +19,14 @@ BASE_DIR = Path(__file__).resolve().parent.parent
SECRET_KEY = os.environ.get("SECRET_KEY") SECRET_KEY = os.environ.get("SECRET_KEY")
DEBUG = os.environ.get("DEBUG", default=0) DEBUG = bool(os.environ.get("DEBUG", default=0))
print(DEBUG)
DEBUG = bool(DEBUG)
print(DEBUG)
# 'DJANGO_ALLOWED_HOSTS' should be a single string of hosts with a space between each. # 'DJANGO_ALLOWED_HOSTS' should be a single string of hosts with a space between each.
# For example: 'DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1]' # For example: 'DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1]'
try:
ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS").split(" ") ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS").split(" ")
except:
ALLOWED_HOSTS = ["127.0.0.1", "localhost"]
INSTALLED_APPS = [ INSTALLED_APPS = [
'explorer.apps.ExplorerConfig', 'explorer.apps.ExplorerConfig',

View File

@ -1,4 +1,4 @@
{ pkgs ? import <nixpkgs> {} }: { pkgs ? import <nixpkgs> {} }:
pkgs.mkShell { pkgs.mkShell {
nativeBuildInputs = with pkgs.python311Packages; [ django pymupdf ] ++ [pkgs.docker-compose] ; nativeBuildInputs = with pkgs.python311Packages; [ django pymupdf ] ++ [pkgs.docker-compose pkgs.gnumake] ;
} }