From 1bdd63fd2ad372bf2e7296572f6f387edc71e68b Mon Sep 17 00:00:00 2001 From: WGAVermeer <90707235+WGAVermeer@users.noreply.github.com> Date: Fri, 6 Mar 2026 14:52:57 +0100 Subject: [PATCH] initial django build using docker and gunicorn. --- Dockerfile | 23 ++++++++ compose.yaml | 5 ++ gunicorn.conf.py | 1 + quatsh/manage.py | 22 +++++++ quatsh/website/__init__.py | 0 quatsh/website/asgi.py | 16 +++++ quatsh/website/settings.py | 117 +++++++++++++++++++++++++++++++++++++ quatsh/website/urls.py | 22 +++++++ quatsh/website/wsgi.py | 16 +++++ requirements.txt | 2 + 10 files changed, 224 insertions(+) create mode 100644 Dockerfile create mode 100644 compose.yaml create mode 100644 gunicorn.conf.py create mode 100644 quatsh/manage.py create mode 100644 quatsh/website/__init__.py create mode 100644 quatsh/website/asgi.py create mode 100644 quatsh/website/settings.py create mode 100644 quatsh/website/urls.py create mode 100644 quatsh/website/wsgi.py create mode 100644 requirements.txt diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..457c4ea --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM python:3.14-alpine + +RUN mkdir /app + +WORKDIR /app + +ENV PYTHONDONTWRITEBYTECODE=1 + +ENV PYTHONUNBUFFERED=1 + +RUN pip install --upgrade pip + +COPY requirements.txt /app/ +COPY gunicorn.conf.py /app/ + +RUN pip install --no-cache-dir -r requirements.txt + +COPY ./quatsh/ /app/ + +EXPOSE 8000 + +CMD ["gunicorn", "website.wsgi:application"] + diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..ddccc4c --- /dev/null +++ b/compose.yaml @@ -0,0 +1,5 @@ +services: + web: + build: . + ports: + - 8000:8000 diff --git a/gunicorn.conf.py b/gunicorn.conf.py new file mode 100644 index 0000000..dc574f2 --- /dev/null +++ b/gunicorn.conf.py @@ -0,0 +1 @@ +bind = "0.0.0.0:8000" diff --git a/quatsh/manage.py b/quatsh/manage.py new file mode 100644 index 0000000..ac2f90c --- /dev/null +++ b/quatsh/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'website.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/quatsh/website/__init__.py b/quatsh/website/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/quatsh/website/asgi.py b/quatsh/website/asgi.py new file mode 100644 index 0000000..b747354 --- /dev/null +++ b/quatsh/website/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for website project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/6.0/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'website.settings') + +application = get_asgi_application() diff --git a/quatsh/website/settings.py b/quatsh/website/settings.py new file mode 100644 index 0000000..cc91025 --- /dev/null +++ b/quatsh/website/settings.py @@ -0,0 +1,117 @@ +""" +Django settings for website project. + +Generated by 'django-admin startproject' using Django 6.0.3. + +For more information on this file, see +https://docs.djangoproject.com/en/6.0/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/6.0/ref/settings/ +""" + +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/6.0/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'django-insecure-c$q7wdq+u@ow74wp!&zzkxdylkueu)(+34e%!e0du&bjwoqz9z' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'website.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'website.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/6.0/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/6.0/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/6.0/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/6.0/howto/static-files/ + +STATIC_URL = 'static/' diff --git a/quatsh/website/urls.py b/quatsh/website/urls.py new file mode 100644 index 0000000..ac9ab57 --- /dev/null +++ b/quatsh/website/urls.py @@ -0,0 +1,22 @@ +""" +URL configuration for website project. + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/6.0/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import path + +urlpatterns = [ + path('admin/', admin.site.urls), +] diff --git a/quatsh/website/wsgi.py b/quatsh/website/wsgi.py new file mode 100644 index 0000000..48143b4 --- /dev/null +++ b/quatsh/website/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for website project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/6.0/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'website.settings') + +application = get_wsgi_application() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..76a2a45 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +Django==6.0.3 +gunicorn==25.1.0