├── .dockerignore ├── .gitignore ├── Dockerfile ├── LICENSE ├── README.md ├── docker-compose.dev.yaml └── src ├── cfehome ├── __init__.py ├── asgi.py ├── db.py ├── env.py ├── settings.py ├── urls.py └── wsgi.py ├── config ├── entrypoint.sh └── migrate.sh ├── manage.py └── requirements.txt /.dockerignore: -------------------------------------------------------------------------------- 1 | Article.md 2 | src/.env 3 | src-old/ 4 | .DS_STORE 5 | 6 | # Virtualenv related 7 | bin/ 8 | include/ 9 | pip-selfcheck.json 10 | 11 | # Django related 12 | # src//settings/local.py 13 | # static-cdn/ # any collected static files 14 | 15 | 16 | # Byte-compiled / optimized / DLL files 17 | __pycache__/ 18 | *.py[cod] 19 | *$py.class 20 | 21 | # C extensions 22 | *.so 23 | 24 | # Distribution / packaging 25 | .Python 26 | build/ 27 | develop-eggs/ 28 | dist/ 29 | downloads/ 30 | eggs/ 31 | .eggs/ 32 | lib/ 33 | lib64/ 34 | parts/ 35 | sdist/ 36 | var/ 37 | wheels/ 38 | *.egg-info/ 39 | .installed.cfg 40 | *.egg 41 | 42 | # PyInstaller 43 | # Usually these files are written by a python script from a template 44 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 45 | *.manifest 46 | *.spec 47 | 48 | # Installer logs 49 | pip-log.txt 50 | pip-delete-this-directory.txt 51 | 52 | # Unit test / coverage reports 53 | htmlcov/ 54 | .tox/ 55 | .coverage 56 | .coverage.* 57 | .cache 58 | nosetests.xml 59 | coverage.xml 60 | *.cover 61 | .hypothesis/ 62 | 63 | # Translations 64 | *.mo 65 | *.pot 66 | 67 | # Django stuff: 68 | *.log 69 | local_settings.py 70 | 71 | # Flask stuff: 72 | instance/ 73 | .webassets-cache 74 | 75 | # Scrapy stuff: 76 | .scrapy 77 | 78 | # Sphinx documentation 79 | docs/_build/ 80 | 81 | # PyBuilder 82 | target/ 83 | 84 | # Jupyter Notebook 85 | .ipynb_checkpoints 86 | 87 | # pyenv 88 | .python-version 89 | 90 | # celery beat schedule file 91 | celerybeat-schedule 92 | 93 | # SageMath parsed files 94 | *.sage.py 95 | 96 | # Environments 97 | .env 98 | .venv 99 | env/ 100 | venv/ 101 | ENV/ 102 | 103 | # Spyder project settings 104 | .spyderproject 105 | .spyproject 106 | 107 | # Rope project settings 108 | .ropeproject 109 | 110 | # mkdocs documentation 111 | /site 112 | 113 | # mypy 114 | .mypy_cache/ 115 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Article.md 2 | src/.env 3 | src-old/ 4 | .DS_STORE 5 | 6 | # Virtualenv related 7 | bin/ 8 | include/ 9 | pip-selfcheck.json 10 | 11 | # Django related 12 | # src//settings/local.py 13 | # static-cdn/ # any collected static files 14 | 15 | 16 | # Byte-compiled / optimized / DLL files 17 | __pycache__/ 18 | *.py[cod] 19 | *$py.class 20 | 21 | # C extensions 22 | *.so 23 | 24 | # Distribution / packaging 25 | .Python 26 | build/ 27 | develop-eggs/ 28 | dist/ 29 | downloads/ 30 | eggs/ 31 | .eggs/ 32 | lib/ 33 | lib64/ 34 | parts/ 35 | sdist/ 36 | var/ 37 | wheels/ 38 | *.egg-info/ 39 | .installed.cfg 40 | *.egg 41 | 42 | # PyInstaller 43 | # Usually these files are written by a python script from a template 44 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 45 | *.manifest 46 | *.spec 47 | 48 | # Installer logs 49 | pip-log.txt 50 | pip-delete-this-directory.txt 51 | 52 | # Unit test / coverage reports 53 | htmlcov/ 54 | .tox/ 55 | .coverage 56 | .coverage.* 57 | .cache 58 | nosetests.xml 59 | coverage.xml 60 | *.cover 61 | .hypothesis/ 62 | 63 | # Translations 64 | *.mo 65 | *.pot 66 | 67 | # Django stuff: 68 | *.log 69 | local_settings.py 70 | 71 | # Flask stuff: 72 | instance/ 73 | .webassets-cache 74 | 75 | # Scrapy stuff: 76 | .scrapy 77 | 78 | # Sphinx documentation 79 | docs/_build/ 80 | 81 | # PyBuilder 82 | target/ 83 | 84 | # Jupyter Notebook 85 | .ipynb_checkpoints 86 | 87 | # pyenv 88 | .python-version 89 | 90 | # celery beat schedule file 91 | celerybeat-schedule 92 | 93 | # SageMath parsed files 94 | *.sage.py 95 | 96 | # Environments 97 | .env 98 | .venv 99 | env/ 100 | venv/ 101 | ENV/ 102 | 103 | # Spyder project settings 104 | .spyderproject 105 | .spyproject 106 | 107 | # Rope project settings 108 | .ropeproject 109 | 110 | # mkdocs documentation 111 | /site 112 | 113 | # mypy 114 | .mypy_cache/ 115 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.11.1-slim as builder 2 | 3 | # copy project 4 | COPY ./src /app 5 | WORKDIR /app 6 | 7 | # Update system environment 8 | ENV PYTHON_VERSION=3.10 9 | ENV DEBIAN_FRONTEND noninteractive 10 | ENV LANG en_US.UTF-8 11 | ENV LANGUAGE en_US:en 12 | ENV LC_ALL en_US.UTF-8 13 | 14 | # Update system defaults 15 | RUN apt-get update && \ 16 | apt-get install -y \ 17 | locales \ 18 | libmemcached-dev \ 19 | libpq-dev \ 20 | libjpeg-dev \ 21 | zlib1g-dev \ 22 | build-essential \ 23 | python3-dev \ 24 | python3-setuptools \ 25 | gcc \ 26 | make && \ 27 | apt-get clean && \ 28 | rm -rf /var/lib/apt/lists/* 29 | 30 | # Update Locales 31 | RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \ 32 | && locale-gen && dpkg-reconfigure locales 33 | 34 | 35 | # Install Python deps 36 | RUN python3 -m venv /opt/venv && \ 37 | /opt/venv/bin/python -m pip install pip --upgrade && \ 38 | /opt/venv/bin/python -m pip install -r /app/requirements.txt 39 | 40 | # Purge unused 41 | RUN apt-get remove -y --purge make gcc build-essential \ 42 | && apt-get autoremove -y \ 43 | && rm -rf /var/lib/apt/lists/* 44 | 45 | # Make local files executable 46 | RUN chmod +x config/migrate.sh && \ 47 | chmod +x config/entrypoint.sh 48 | 49 | CMD [ "./config/entrypoint.sh" ] -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Coding For Entrepreneurs 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Create a Blank Django Project Logo](https://cfe2-static.s3-us-west-2.amazonaws.com/media/cfe-blog/create-a-blank-django-project/BlankDjangoProject.jpg)](https://www.codingforentrepreneurs.com/blog/create-a-blank-django-project/) 2 | 3 | # CFE Blank Project 4 | 5 | This is a blank Django project that can be used as a starting point for any Django project. It includes related Docker and Docker Compose configuration for local development with Postgres and Redis. 6 | 7 | We'll continue to refine this project based on requests from people like you. If you have any suggestions or want to submit ideas, please do so on [github discussions](https://github.com/codingforentrepreneurs/CFE-Blank-Project/discussions). 8 | 9 | _Reference blog post coming soon_. 10 | 11 | ## Get Started 12 | 13 | 14 | ### Clone project 15 | ``` 16 | mkdir -p ~/Dev/your-project 17 | cd ~/Dev/your-project 18 | git clone https://github.com/codingforentrepreneurs/CFE-Blank-Project . 19 | ``` 20 | 21 | ### Create a Python Virtual Environment 22 | Using Python 3.11, create a virtual environment using the built-in `venv` module: 23 | 24 | _macOS/Linux_: 25 | ``` 26 | python3.11 -m venv venv 27 | source venv/bin/activate 28 | $(venv) python --version 29 | ``` 30 | 31 | _Windows_: 32 | ``` 33 | c:\>Python311\python -m venv venv 34 | .\venv\Scripts\activate 35 | (venv) > python --version 36 | ``` 37 | If you're on Windows, consider install Python using [this guide](https://www.codingforentrepreneurs.com/guides/install-python-on-windows/) or [this blog post](https://www.codingforentrepreneurs.com/blog/install-python-django-on-windows/). 38 | 39 | 40 | ### Install requirements 41 | ``` 42 | $(venv) python -m pip install -r src/requirements.txt 43 | ``` 44 | 45 | 46 | ### Configure Environment Variables 47 | 48 | In `src/.env` add: 49 | ``` 50 | DJANGO_DEBUG=True 51 | DJANGO_SECRET_KEY=your-secret-key 52 | ALLOWED_HOSTS=.codingforentrepreneurs.com,.cfe.sh,localhost,127.0.0.1 53 | ``` 54 | 55 | You can generate a Django Secret Key with ([reference post](https://www.codingforentrepreneurs.com/blog/create-a-one-off-django-secret-key/)) the following: 56 | 57 | ```bash 58 | $(venv) python -c 'from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())' 59 | ``` 60 | 61 | ### Various Django Commands 62 | 63 | Below are a few commands that will work for this configuration both before and after using the database configuration and the _docker-compose_-based configuration below. 64 | ``` 65 | $(venv) python manage.py makemigrations 66 | $(venv) python manage.py migrate 67 | $(venv) python manage.py createsuperuser 68 | ``` 69 | 70 | 71 | ### Configuring for Postgres Database 72 | 73 | In `src/cfehome/db.py` you will see a Postgres database configuration based on available environment variables. Do _not_ change the variable names _without_ changing several other configurations (at least `src/cfehome/db.py`, `docker-compose.yaml`). 74 | 75 | Update `.env` or your environment variables to include the following configuration 76 | ``` 77 | POSTGRES_USER=... 78 | POSTGRES_PASSWORD=... 79 | POSTGRES_DB=... 80 | POSTGRES_HOST=localhost 81 | POSTGRES_PORT=5432 82 | ``` 83 | You can also set `POSTGRES_DB_REQUIRE_SSL=True` if you want to require SSL connections to the database. 84 | 85 | 86 | ### Using Docker Compose for Postgres and Redis 87 | Assuming you have the POSTGRES environment variables set, you can use Docker Compose to create development Postgres database for your project. 88 | 89 | To start the Postgres database and Redis, run: 90 | ``` 91 | docker compose -f docker-compose.dev.yaml up -d 92 | ``` 93 | This sets our Postgres database to be available at `localhost:5432` and Redis at `localhost:6379`. 94 | 95 | To stop and remove your Postgres database and Redis, run: 96 | ``` 97 | docker compose -f docker-compose.dev.yaml down 98 | ``` 99 | Use `docker compose -f docker-compose.dev.yaml down -v` to remove the volumes as well. 100 | 101 | _If you need to learn about how to use Docker & Docker Compose, consider [this course](https://www.codingforentrepreneurs.com/courses/docker-and-docker-compose/)._ 102 | 103 | 104 | ### Docker Image for Django Local Development 105 | 106 | To build the Docker image, run: 107 | ``` 108 | docker build -t cfe-blank-project . 109 | ``` 110 | 111 | Update `POSTGRES_HOST` in `.env` to use `host.docker.internal` if you are using the local `docker-compose` Postgres database. 112 | 113 | To run the Docker image locally, run: 114 | ``` 115 | docker run --network cfe_blank_network -p 8000:8000 -e -e PORT=8000 --env-file src/.env cfe-blank-project --name cfe-blank-project 116 | ``` 117 | 118 | To stop the Docker container, run: 119 | ``` 120 | docker stop cfe-blank-project 121 | ``` 122 | In this case `cfe-blank-project` is the name of the container we set in the previous command with `--name cfe-blank-project`. 123 | 124 | 125 | 126 | ### Production Configuration 127 | Would you like this project to be augmented for a minimal production environment as well? If so, please start a [discussion](https://github.com/codingforentrepreneurs/CFE-Blank-Project/discussions) requesting so. 128 | -------------------------------------------------------------------------------- /docker-compose.dev.yaml: -------------------------------------------------------------------------------- 1 | version: '3.9' 2 | services: 3 | db: 4 | image: postgres 5 | restart: always 6 | ports: 7 | - 5432:5432 8 | volumes: 9 | - postgresdb_data:/var/lib/postgresql/data/ 10 | env_file: 11 | - src/.env 12 | redis: 13 | image: redis 14 | restart: always 15 | ports: 16 | - 6379:6379 17 | volumes: 18 | - redis_data:/data 19 | entrypoint: redis-server --appendonly yes 20 | 21 | volumes: 22 | postgresdb_data: 23 | redis_data: 24 | 25 | networks: 26 | default: 27 | name: cfe_blank_network -------------------------------------------------------------------------------- /src/cfehome/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codingforentrepreneurs/CFE-Blank-Project/47dbff80a2ec0bc71c55ff0a4589f55f3164c9e6/src/cfehome/__init__.py -------------------------------------------------------------------------------- /src/cfehome/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for cfehome project. 3 | 4 | It exposes the ASGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.asgi import get_asgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'cfehome.settings') 15 | 16 | application = get_asgi_application() 17 | -------------------------------------------------------------------------------- /src/cfehome/db.py: -------------------------------------------------------------------------------- 1 | from cfehome.env import config 2 | 3 | POSTGRES_USER = config("POSTGRES_USER", default=None) 4 | POSTGRES_PASSWORD = config("POSTGRES_PASSWORD", default=None) 5 | POSTGRES_DB = config("POSTGRES_DB", default=None) 6 | POSTGRES_HOST = config("POSTGRES_HOST", default=None) 7 | POSTGRES_PORT = config("POSTGRES_PORT", default=None) 8 | POSTGRES_DB_IS_AVAIL = all( 9 | [POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB, POSTGRES_HOST, POSTGRES_PORT] 10 | ) 11 | POSTGRES_DB_REQUIRE_SSL = config("POSTGRES_DB_REQUIRE_SSL", cast=bool, default=False) 12 | 13 | if POSTGRES_DB_IS_AVAIL: 14 | DATABASES = { 15 | "default": { 16 | "ENGINE": "django.db.backends.postgresql", 17 | "NAME": POSTGRES_DB, 18 | "USER": POSTGRES_USER, 19 | "PASSWORD": POSTGRES_PASSWORD, 20 | "HOST": POSTGRES_HOST, 21 | "PORT": POSTGRES_PORT, 22 | } 23 | } 24 | if POSTGRES_DB_REQUIRE_SSL: 25 | DATABASES["default"]["OPTIONS"] = {"sslmode": "require"} 26 | -------------------------------------------------------------------------------- /src/cfehome/env.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | from functools import lru_cache 3 | 4 | from decouple import Config, RepositoryEnv 5 | 6 | BASE_DIR = pathlib.Path(__file__).parent.parent 7 | 8 | ENV_PATH = BASE_DIR / ".env" 9 | 10 | 11 | @lru_cache() 12 | def get_config(): 13 | if ENV_PATH.exists(): 14 | return Config(RepositoryEnv(ENV_PATH)) 15 | from decouple import config 16 | 17 | return config 18 | 19 | 20 | config = get_config() 21 | -------------------------------------------------------------------------------- /src/cfehome/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for cfehome project. 3 | 4 | Generated by 'django-admin startproject' using Django 4.1.5. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.1/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/4.1/ref/settings/ 11 | """ 12 | 13 | from pathlib import Path 14 | 15 | # Configure python-decouple's Environment Variables loader 16 | from cfehome.env import config 17 | 18 | # Build paths inside the project like this: BASE_DIR / 'subdir'. 19 | BASE_DIR = Path(__file__).resolve().parent.parent 20 | 21 | 22 | # Quick-start development settings - unsuitable for production 23 | # See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/ 24 | 25 | # SECURITY WARNING: keep the secret key used in production secret! 26 | 27 | SECRET_KEY = config('DJANGO_SECRET_KEY', default='django-insecure-sad9nbu^y)_=vv78s4^k%e7zmo!9&w!$z=0s04*wqe1)krggmr') 28 | 29 | # SECURITY WARNING: don't run with debug turned on in production! 30 | DEBUG = config('DJANGO_DEBUG', cast=bool, default=True) 31 | 32 | ALLOWED_HOSTS = [] 33 | 34 | # In your environment variables set 35 | # ALLOWED_HOSTS="host-one.com,.host-two.com" 36 | # To use this setting 37 | ENV_ALLOWED_HOSTS = config("ALLOWED_HOSTS", default=None) 38 | if ENV_ALLOWED_HOSTS is not None: 39 | ALLOWED_HOSTS += [x.strip() for x in ENV_ALLOWED_HOSTS.split(",")] 40 | 41 | 42 | # Application definition 43 | 44 | INSTALLED_APPS = [ 45 | 'django.contrib.admin', 46 | 'django.contrib.auth', 47 | 'django.contrib.contenttypes', 48 | 'django.contrib.sessions', 49 | 'django.contrib.messages', 50 | 'django.contrib.staticfiles', 51 | ] 52 | 53 | MIDDLEWARE = [ 54 | 'django.middleware.security.SecurityMiddleware', 55 | 'django.contrib.sessions.middleware.SessionMiddleware', 56 | 'django.middleware.common.CommonMiddleware', 57 | 'django.middleware.csrf.CsrfViewMiddleware', 58 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 59 | 'django.contrib.messages.middleware.MessageMiddleware', 60 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 61 | ] 62 | 63 | ROOT_URLCONF = 'cfehome.urls' 64 | 65 | TEMPLATES = [ 66 | { 67 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 68 | 'DIRS': [], 69 | 'APP_DIRS': True, 70 | 'OPTIONS': { 71 | 'context_processors': [ 72 | 'django.template.context_processors.debug', 73 | 'django.template.context_processors.request', 74 | 'django.contrib.auth.context_processors.auth', 75 | 'django.contrib.messages.context_processors.messages', 76 | ], 77 | }, 78 | }, 79 | ] 80 | 81 | WSGI_APPLICATION = 'cfehome.wsgi.application' 82 | 83 | 84 | # Database 85 | # https://docs.djangoproject.com/en/4.1/ref/settings/#databases 86 | 87 | DATABASES = { 88 | 'default': { 89 | 'ENGINE': 'django.db.backends.sqlite3', 90 | 'NAME': BASE_DIR / 'db.sqlite3', 91 | } 92 | } 93 | 94 | # Import PostgreSQL Configuration 95 | from .db import * # noqa 96 | 97 | # Password validation 98 | # https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators 99 | 100 | AUTH_PASSWORD_VALIDATORS = [ 101 | { 102 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 103 | }, 104 | { 105 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 106 | }, 107 | { 108 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 109 | }, 110 | { 111 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 112 | }, 113 | ] 114 | 115 | 116 | # Internationalization 117 | # https://docs.djangoproject.com/en/4.1/topics/i18n/ 118 | 119 | LANGUAGE_CODE = 'en-us' 120 | 121 | TIME_ZONE = 'UTC' 122 | 123 | USE_I18N = True 124 | 125 | USE_TZ = True 126 | 127 | 128 | # Static files (CSS, JavaScript, Images) 129 | # https://docs.djangoproject.com/en/4.1/howto/static-files/ 130 | 131 | STATIC_URL = 'static/' 132 | 133 | # Default primary key field type 134 | # https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field 135 | 136 | DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' 137 | -------------------------------------------------------------------------------- /src/cfehome/urls.py: -------------------------------------------------------------------------------- 1 | """cfehome URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/4.1/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | from django.contrib import admin 17 | from django.urls import path 18 | 19 | urlpatterns = [ 20 | path('admin/', admin.site.urls), 21 | ] 22 | -------------------------------------------------------------------------------- /src/cfehome/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for cfehome project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.1/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'cfehome.settings') 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /src/config/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # set the running gunicorn port 4 | # based on a Environment variable 5 | APP_PORT=${PORT:-8000} 6 | 7 | # go to the docker-created app directory 8 | # where the code is copied 9 | cd /app/ 10 | 11 | # Use the docker-created virtualenv 12 | /opt/venv/bin/python manage.py migrate 13 | 14 | # run the gunicorn server on the cfehome.wsgi:application 15 | /opt/venv/bin/gunicorn cfehome.wsgi:application --bind "0.0.0.0:$APP_PORT" -------------------------------------------------------------------------------- /src/config/migrate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # navigate to the docker-created 4 | # django project root directory 5 | cd /app/ 6 | 7 | # migrate a docker container as needed 8 | /opt/venv/bin/python manage.py migrate -------------------------------------------------------------------------------- /src/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | import os 4 | import sys 5 | 6 | 7 | def main(): 8 | """Run administrative tasks.""" 9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'cfehome.settings') 10 | try: 11 | from django.core.management import execute_from_command_line 12 | except ImportError as exc: 13 | raise ImportError( 14 | "Couldn't import Django. Are you sure it's installed and " 15 | "available on your PYTHONPATH environment variable? Did you " 16 | "forget to activate a virtual environment?" 17 | ) from exc 18 | execute_from_command_line(sys.argv) 19 | 20 | 21 | if __name__ == '__main__': 22 | main() 23 | -------------------------------------------------------------------------------- /src/requirements.txt: -------------------------------------------------------------------------------- 1 | Django>=4.1.0,<4.2.0 2 | python-decouple 3 | psycopg2 4 | gunicorn --------------------------------------------------------------------------------