Skip to content

Commit

Permalink
Updated README and moved to Django 4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Astronaut101 committed Feb 2, 2024
1 parent 2b22c11 commit 63aa78f
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 39 deletions.
31 changes: 24 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
# Content Engine 💼🧑‍💻

# Django Auto Container
Following the Django tutorial from the amazing [CodingEntrepreneurs Youtube Channel](https://youtu.be/2TX7Pal5NMc?si=TSSnyYbooBOp7-KL), this focuses on building a modern fullstack Django web application while using modern DevOps tooling to help build production grade Django Web apps.

## Tech stack

This repository contains a GitHub Actions workflow that automatically builds a Django-based container application and pushes it to Docker Hub using Buildpacks.
* Django 🐍
* Kubernetes ⛵
* TailwindCSS 🎨
* Twingate 🔐
* AWS S3 / Azure Storage 🪣
* HTMX ⚙️

The purpose of this repo is to help Django devs use containers without having to learn Docker.
## Django Auto Container

This repository contains a GitHub Actions workflow that automatically builds a Django-based container application and pushes it to Docker Hub using Buildpacks. You can import the repository on your Django Project from CodingEntrepreneurs github repository.

The purpose of this repo is to help Django devs use containers without having to learn Docker.

## Getting Started

Expand All @@ -18,28 +29,34 @@ curl https://raw.githubusercontent.com/codingforentrepreneurs/django-auto-contai
```

### 2. Github Actions Secrets

In your GitHub Repo, add the following Secrets:
#### Required Secrets:

#### Required Secrets

If you do not include these secrets, the container will be built but not hosted anywhere.

- `DOCKER_HUB_USERNAME`: Your Docker Hub username.
- `DOCKER_HUB_TOKEN`: Your Docker Hub access token; create a new token [here](https://hub.docker.com/settings/security).


#### Recommended Secrets:
#### Recommended Secrets

These secrets are highly recommended to add for your specific project.

- `DOCKER_HUB_REPO`: The Docker repository to push to, in the format `username/repository`. Defaults to the format of your GitHub repo if not set -- this is where you will store your container.
- `BASE_DIR`: The default Django project location is `src/` as you see in this repo. If you have a different location, you can set it here.

#### Optional Secrets:
#### Optional Secrets

If you need more advanced usage, consider adding these secrets to modify how your project works.

- `BUILDPACK_BUILDER`: The buildpack builder to use. Defaults to 'heroku/buildpacks:22' if not set. Review various Heroku buildpacks [here](https://devcenter.heroku.com/articles/stack#stack-support-details)
- `DOCKER_HUB_IMAGE_TAG`: The tag to use for the Docker image. Defaults to the commit SHA (recommended) or you can set this value yourself.

### 3. Required Files

In my `BASE_DIR` (defaults to `src/`), I have the following files:

- project.toml
- requirements.txt

Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions src/cfehome/asgi.py → src/ce_home/asgi.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
"""
ASGI config for cfehome project.
ASGI config for ce_home 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/5.0/howto/deployment/asgi/
https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cfehome.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ce_home.settings")

application = get_asgi_application()
28 changes: 14 additions & 14 deletions src/cfehome/settings.py → src/ce_home/settings.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""
Django settings for cfehome project.
Django settings for ce_home project.
Generated by 'django-admin startproject' using Django 5.0.1.
Generated by 'django-admin startproject' using Django 4.2.9.
For more information on this file, see
https://docs.djangoproject.com/en/5.0/topics/settings/
https://docs.djangoproject.com/en/4.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.0/ref/settings/
https://docs.djangoproject.com/en/4.2/ref/settings/
"""

from pathlib import Path
Expand All @@ -17,15 +17,15 @@


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "django-insecure-wc(eerg(v$4rdj7ll-6e3p%v*s@g#gk2%*rp8=#$zz7!-3b6^b"
SECRET_KEY = "django-insecure-p97_(^ph=+ybf%pgee)1rlq7ws(q%hqj$vv9lx6sqa%m)lbb@1"

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ["*"]
ALLOWED_HOSTS = []


# Application definition
Expand All @@ -49,7 +49,7 @@
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]

ROOT_URLCONF = "cfehome.urls"
ROOT_URLCONF = "ce_home.urls"

TEMPLATES = [
{
Expand All @@ -67,11 +67,11 @@
},
]

WSGI_APPLICATION = "cfehome.wsgi.application"
WSGI_APPLICATION = "ce_home.wsgi.application"


# Database
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases

DATABASES = {
"default": {
Expand All @@ -82,7 +82,7 @@


# Password validation
# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
Expand All @@ -101,7 +101,7 @@


# Internationalization
# https://docs.djangoproject.com/en/5.0/topics/i18n/
# https://docs.djangoproject.com/en/4.2/topics/i18n/

LANGUAGE_CODE = "en-us"

Expand All @@ -113,11 +113,11 @@


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/5.0/howto/static-files/
# https://docs.djangoproject.com/en/4.2/howto/static-files/

STATIC_URL = "static/"

# Default primary key field type
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
7 changes: 2 additions & 5 deletions src/cfehome/urls.py → src/ce_home/urls.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""
URL configuration for cfehome project.
URL configuration for ce_home project.
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/5.0/topics/http/urls/
https://docs.djangoproject.com/en/4.2/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
Expand All @@ -17,9 +17,6 @@
from django.contrib import admin
from django.urls import path

from . import views

urlpatterns = [
path("", views.hello_world),
path("admin/", admin.site.urls),
]
6 changes: 3 additions & 3 deletions src/cfehome/wsgi.py → src/ce_home/wsgi.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
"""
WSGI config for cfehome project.
WSGI config for ce_home 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/5.0/howto/deployment/wsgi/
https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cfehome.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ce_home.settings")

application = get_wsgi_application()
5 changes: 0 additions & 5 deletions src/cfehome/views.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

def main():
"""Run administrative tasks."""
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cfehome.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ce_home.settings")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
Expand Down
2 changes: 1 addition & 1 deletion src/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Django
Django>=4.2,<4.3
gunicorn

0 comments on commit 63aa78f

Please sign in to comment.