From f8ac92e0ae93348f3552388e30ffb71d812b6613 Mon Sep 17 00:00:00 2001 From: stupidcomputer Date: Sun, 23 Jun 2024 14:05:43 -0500 Subject: [PATCH] docker-composing the debug=True version works --- .env.dev | 3 +++ docker-compose.yml | 10 +++++----- franklincce/Dockerfile | 5 +---- franklincce/franklincce/settings.py | 17 +++++++---------- shell.nix | 2 +- 5 files changed, 17 insertions(+), 20 deletions(-) create mode 100644 .env.dev diff --git a/.env.dev b/.env.dev new file mode 100644 index 0000000..7c4be38 --- /dev/null +++ b/.env.dev @@ -0,0 +1,3 @@ +DEBUG=1 +SECRET_KEY=foo +DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1] diff --git a/docker-compose.yml b/docker-compose.yml index 3f0bbdf..d4287d3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,10 +1,10 @@ -version: '3.8' - services: web: - build: ./franklincce - command: gunicorn franklincce.wsgi:application --bind 0.0.0.0:8000 + build: ./app + command: python manage.py runserver 0.0.0.0:8000 volumes: - - ./franklincce/:/usr/src/franklincce + - ./franklincce/:/usr/src/app/ ports: - 8000:8000 + env_file: + - ./.env.dev diff --git a/franklincce/Dockerfile b/franklincce/Dockerfile index 166c076..f09a3ef 100644 --- a/franklincce/Dockerfile +++ b/franklincce/Dockerfile @@ -1,3 +1,4 @@ +# pull official base image FROM python:3.11.4-slim-buster # set work directory @@ -12,9 +13,5 @@ RUN pip install --upgrade pip COPY ./requirements.txt . RUN pip install -r requirements.txt - # copy project COPY . . - -RUN mkdir /var/www/static -p -RUN python3 manage.py collectstatic --noinput diff --git a/franklincce/franklincce/settings.py b/franklincce/franklincce/settings.py index 6b4173a..7a3be34 100644 --- a/franklincce/franklincce/settings.py +++ b/franklincce/franklincce/settings.py @@ -10,23 +10,20 @@ For the full list of settings and their values, see https://docs.djangoproject.com/en/4.2/ref/settings/ """ +import os + from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent -# Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/ +SECRET_KEY = os.environ.get("SECRET_KEY") -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'django-insecure-1%p#re)z*_xd9umo0!1foh(yiz&2=*5q#0b4(m42r0^m%kxli#' +DEBUG = bool(os.environ.get("DEBUG", default=0)) -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True - -ALLOWED_HOSTS = ["localhost", "192.168.0.87", "127.0.0.1", "[::1]"] - -# Application definition +# '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]' +ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS").split(" ") INSTALLED_APPS = [ 'explorer.apps.ExplorerConfig', diff --git a/shell.nix b/shell.nix index 56a0930..a5ee2e3 100644 --- a/shell.nix +++ b/shell.nix @@ -1,4 +1,4 @@ { pkgs ? import {} }: pkgs.mkShell { - nativeBuildInputs = with pkgs.python311Packages; [ django pymupdf ]; + nativeBuildInputs = with pkgs.python311Packages; [ django pymupdf docker-compose ]; }