Skip to content

Commit 4e53bfa

Browse files
committed
Added CORE Structure
1 parent d2b0b7e commit 4e53bfa

25 files changed

+367
-0
lines changed

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*.pyc
2+
*.DS_Store
3+
*.egg*
4+
/dist/
5+
/.idea
6+
/docs/_build/
7+
/node_modules/
8+
build/
9+
env
10+
/staticfiles/
11+
12+
#src
13+
*.sqlite*
14+
15+
.env

Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM python:3.11.5
2+
3+
# set environment variables
4+
ENV PYTHONDONTWRITEBYTECODE 1
5+
ENV PYTHONUNBUFFERED 1
6+
7+
COPY requirements.txt .
8+
# install python dependencies
9+
RUN pip install --upgrade pip
10+
RUN pip install --no-cache-dir -r requirements.txt
11+
12+
COPY . .
13+
14+
# DB & Statics
15+
RUN python manage.py collectstatic --no-input
16+
RUN python manage.py migrate
17+
18+
# gunicorn
19+
CMD ["gunicorn", "--config", "gunicorn-cfg.py", "core.wsgi"]

build.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
# exit on error
3+
set -o errexit
4+
5+
python -m pip install --upgrade pip
6+
7+
pip install -r requirements.txt
8+
9+
python manage.py collectstatic --no-input
10+
python manage.py migrate

core/__init__.py

Whitespace-only changes.

core/asgi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
ASGI config for core 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.2/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", "core.settings")
15+
16+
application = get_asgi_application()

core/settings.py

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
"""
2+
Django settings for core project.
3+
4+
Generated by 'django-admin startproject' using Django 4.2.5.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/4.2/topics/settings/
8+
9+
For the full list of settings and their values, see
10+
https://docs.djangoproject.com/en/4.2/ref/settings/
11+
"""
12+
13+
import os, random, string
14+
from pathlib import Path
15+
from dotenv import load_dotenv
16+
from distutils.util import strtobool
17+
18+
load_dotenv() # take environment variables from .env.
19+
20+
# Build paths inside the project like this: BASE_DIR / 'subdir'.
21+
BASE_DIR = Path(__file__).resolve().parent.parent
22+
23+
# Quick-start development settings - unsuitable for production
24+
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
25+
26+
# SECURITY WARNING: keep the secret key used in production secret!
27+
SECRET_KEY = os.environ.get('SECRET_KEY')
28+
if not SECRET_KEY:
29+
SECRET_KEY = ''.join(random.choice( string.ascii_lowercase ) for i in range( 32 ))
30+
31+
# SECURITY WARNING: don't run with debug turned on in production!
32+
DEBUG = strtobool(os.getenv('DEBUG', "True"))
33+
34+
if DEBUG:
35+
print(' DEBUG -> ON (development)')
36+
else:
37+
print(' DEBUG -> OFF (production)')
38+
39+
# Hosts Settings
40+
ALLOWED_HOSTS = ['localhost', '127.0.0.1']
41+
CSRF_TRUSTED_ORIGINS = ['http://localhost:8000', 'http://localhost:5085', 'http://127.0.0.1:8000', 'http://127.0.0.1:5085']
42+
43+
# Application definition
44+
45+
INSTALLED_APPS = [
46+
"django.contrib.admin",
47+
"django.contrib.auth",
48+
"django.contrib.contenttypes",
49+
"django.contrib.sessions",
50+
"django.contrib.messages",
51+
"django.contrib.staticfiles",
52+
53+
"home",
54+
]
55+
56+
MIDDLEWARE = [
57+
"django.middleware.security.SecurityMiddleware",
58+
"whitenoise.middleware.WhiteNoiseMiddleware",
59+
"django.contrib.sessions.middleware.SessionMiddleware",
60+
"django.middleware.common.CommonMiddleware",
61+
"django.middleware.csrf.CsrfViewMiddleware",
62+
"django.contrib.auth.middleware.AuthenticationMiddleware",
63+
"django.contrib.messages.middleware.MessageMiddleware",
64+
"django.middleware.clickjacking.XFrameOptionsMiddleware",
65+
]
66+
67+
ROOT_URLCONF = "core.urls"
68+
69+
TEMPLATES = [
70+
{
71+
"BACKEND": "django.template.backends.django.DjangoTemplates",
72+
"DIRS": [],
73+
"APP_DIRS": True,
74+
"OPTIONS": {
75+
"context_processors": [
76+
"django.template.context_processors.debug",
77+
"django.template.context_processors.request",
78+
"django.contrib.auth.context_processors.auth",
79+
"django.contrib.messages.context_processors.messages",
80+
],
81+
},
82+
},
83+
]
84+
85+
WSGI_APPLICATION = "core.wsgi.application"
86+
87+
88+
# Database
89+
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
90+
91+
DATABASES = {
92+
"default": {
93+
"ENGINE": "django.db.backends.sqlite3",
94+
"NAME": BASE_DIR / "db.sqlite3",
95+
}
96+
}
97+
98+
99+
# Password validation
100+
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
101+
102+
AUTH_PASSWORD_VALIDATORS = [
103+
{
104+
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
105+
},
106+
{
107+
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
108+
},
109+
{
110+
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
111+
},
112+
{
113+
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
114+
},
115+
]
116+
117+
118+
# Internationalization
119+
# https://docs.djangoproject.com/en/4.2/topics/i18n/
120+
121+
LANGUAGE_CODE = "en-us"
122+
123+
TIME_ZONE = "UTC"
124+
125+
USE_I18N = True
126+
127+
USE_TZ = True
128+
129+
130+
# Static files (CSS, JavaScript, Images)
131+
# https://docs.djangoproject.com/en/4.2/howto/static-files/
132+
133+
STATIC_URL = "static/"
134+
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
135+
136+
# Default primary key field type
137+
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
138+
139+
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"

core/urls.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""
2+
URL configuration for core project.
3+
4+
The `urlpatterns` list routes URLs to views. For more information please see:
5+
https://docs.djangoproject.com/en/4.2/topics/http/urls/
6+
Examples:
7+
Function views
8+
1. Add an import: from my_app import views
9+
2. Add a URL to urlpatterns: path('', views.home, name='home')
10+
Class-based views
11+
1. Add an import: from other_app.views import Home
12+
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
13+
Including another URLconf
14+
1. Import the include() function: from django.urls import include, path
15+
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
16+
"""
17+
from django.contrib import admin
18+
from django.urls import include, path
19+
20+
urlpatterns = [
21+
path("", include("home.urls")),
22+
path("admin/", admin.site.urls),
23+
]

core/wsgi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
WSGI config for core 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.2/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", "core.settings")
15+
16+
application = get_wsgi_application()

docker-compose.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
version: '3.8'
2+
services:
3+
rocket-django:
4+
container_name: rocket_django
5+
restart: always
6+
build: .
7+
networks:
8+
- db_network
9+
- web_network
10+
nginx:
11+
container_name: nginx
12+
restart: always
13+
image: "nginx:latest"
14+
ports:
15+
- "5085:5085"
16+
volumes:
17+
- ./nginx:/etc/nginx/conf.d
18+
networks:
19+
- web_network
20+
depends_on:
21+
- rocket-django
22+
networks:
23+
db_network:
24+
driver: bridge
25+
web_network:
26+
driver: bridge
27+

env.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DEBUG=False

0 commit comments

Comments
 (0)