From a9510840f0d13d97c3d2d2c227d0df5c488dbc52 Mon Sep 17 00:00:00 2001 From: App Generator <51070104+app-generator@users.noreply.github.com> Date: Mon, 29 May 2023 11:27:50 +0300 Subject: [PATCH] Release v1.0.2 - Bump Codebase Version --- .gitignore | 16 +++ CHANGELOG.md | 14 ++- Dockerfile | 18 +++ LICENSE.md | 32 +++++ README.md | 237 ++++++++++++++++++------------------ README_deploy.md | 24 ++++ build.sh | 10 ++ core/__init__.py | 0 core/asgi.py | 16 +++ core/settings.py | 170 ++++++++++++++++++++++++++ core/urls.py | 23 ++++ core/wsgi.py | 16 +++ docker-compose.yml | 27 ++++ env.sample | 11 ++ gulpfile.js | 59 +++++++++ gunicorn-cfg.py | 11 ++ home/__init__.py | 0 home/admin.py | 3 + home/apps.py | 6 + home/migrations/__init__.py | 0 home/models.py | 3 + home/tests.py | 3 + home/urls.py | 7 ++ home/views.py | 9 ++ manage.py | 22 ++++ nginx/appseed-app.conf | 15 +++ package.json | 38 ++++++ render.yaml | 15 +++ requirements.txt | 8 ++ static/.gitkeep | 0 templates/.gitkeep | 0 31 files changed, 689 insertions(+), 124 deletions(-) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 LICENSE.md create mode 100644 README_deploy.md create mode 100644 build.sh create mode 100644 core/__init__.py create mode 100644 core/asgi.py create mode 100644 core/settings.py create mode 100644 core/urls.py create mode 100644 core/wsgi.py create mode 100644 docker-compose.yml create mode 100644 env.sample create mode 100644 gulpfile.js create mode 100644 gunicorn-cfg.py create mode 100644 home/__init__.py create mode 100644 home/admin.py create mode 100644 home/apps.py create mode 100644 home/migrations/__init__.py create mode 100644 home/models.py create mode 100644 home/tests.py create mode 100644 home/urls.py create mode 100644 home/views.py create mode 100644 manage.py create mode 100644 nginx/appseed-app.conf create mode 100644 package.json create mode 100644 render.yaml create mode 100644 requirements.txt create mode 100644 static/.gitkeep create mode 100644 templates/.gitkeep diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..85ea496 --- /dev/null +++ b/.gitignore @@ -0,0 +1,16 @@ +*.pyc +*.DS_Store +*.egg* +/dist/ +/.idea +/docs/_build/ +/node_modules/ +build/ +env +/staticfiles/ + +#src +*.sqlite* + +.env +yarn.lock diff --git a/CHANGELOG.md b/CHANGELOG.md index 827ff3f..6f544f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,15 @@ # Change Log +## [1.0.2] 2023-05-29 +### Changes + +- Move to theme-based pattern + - [Django Tabler Admin](https://github.com/app-generator/django-admin-tabler) +- 🚀 `Deployment` + - `CI/CD` flow via `Render` + ## [1.0.1] 2021-01-20 -### Improvements +### Changes - Bump Django Codebase to [v2stable.0.1](https://github.com/app-generator/boilerplate-code-django-dashboard/releases) - Dependencies update (all packages) @@ -11,11 +19,11 @@ - [Origin header checking isn`t performed in older versions](https://docs.djangoproject.com/en/4.0/ref/settings/#csrf-trusted-origins) ## Unreleased -### Bug fixes +### Changes - Patch [#1 - Whitenoise Fix](https://github.com/app-generator/django-dashboard-tabler/issues/1) - WhiteNoiseMiddleware must be positioned right after SecurityMiddleware - Impacted file: [core/settings.py](https://github.com/app-generator/django-dashboard-tabler/blob/master/core/settings.py) / MIDDLEWARE section ## [1.0.0] 2020-01-14 -### Initial Release +### Changes diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..253fafb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM python:3.9 + +# set environment variables +ENV PYTHONDONTWRITEBYTECODE 1 +ENV PYTHONUNBUFFERED 1 + +COPY requirements.txt . +# install python dependencies +RUN pip install --upgrade pip +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . + +# running migrations +RUN python manage.py migrate + +# gunicorn +CMD ["gunicorn", "--config", "gunicorn-cfg.py", "core.wsgi"] diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..5012dd9 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,32 @@ +# MIT License + +Copyright (c) 2019 - present [AppSeed](http://appseed.us/) + +
+ +## Licensing Information + +
+ +| Item | - | +| ---------------------------------- | --- | +| License Type | MIT | +| Use for print | **YES** | +| Create single personal website/app | **YES** | +| Create single website/app for client | **YES** | +| Create multiple website/apps for clients | **YES** | +| Create multiple SaaS applications | **YES** | +| End-product paying users | **YES** | +| Product sale | **YES** | +| Remove footer credits | **YES** | +| --- | --- | +| Remove copyright mentions from source code | NO | +| Production deployment assistance | NO | +| Create HTML/CSS template for sale | NO | +| Create Theme/Template for CMS for sale | NO | +| Separate sale of our UI Elements | NO | + +
+ +--- +For more information regarding licensing, please contact the AppSeed Service < *support@appseed.us* > diff --git a/README.md b/README.md index da20ae5..fdeb487 100644 --- a/README.md +++ b/README.md @@ -1,202 +1,197 @@ -# [Django Dashboard Tabler](https://appseed.us/admin-dashboards/django-dashboard-tabler) +# [Django Dashboard Tabler](https://appseed.us/product/tabler/django/) Open-source **[Django Dashboard](https://appseed.us/admin-dashboards/django)** generated by AppSeed op top of an iconic design. **Tabler** is a open-source admin template crafted by Codecalm agency. It comes with the basic components and set of pre-built pages required to lay the foundation for any application - Design provided by Codecalm. -- 👉 [Django Tabler](https://appseed.us/admin-dashboards/django-dashboard-tabler) - product page +- 👉 [Django Tabler](https://appseed.us/product/tabler/django/) - product page - 👉 [Django tabler](https://django-dashboard-tabler.appseed.us/) - LIVE App
> Features -- `Up-to-date dependencies` -- UI-Ready app, `SQLite Database`, Django Native ORM -- `Session-Based authentication`, Forms validation -- `Deployment`: **Docker**, Gunicorn / Nginx, HEROKU -- Support via **Github** (issues tracker) and [Discord](https://discord.gg/fZC6hup). +- ✅ `Up-to-date Dependencies` +- ✅ `Design`: [Django Theme Tabler](https://github.com/app-generator/django-admin-tabler) +- ✅ `Sections` covered by the design: + - ✅ **Admin section** (reserved for superusers) + - ✅ **Authentication**: `Django.contrib.AUTH`, Registration + - ✅ **All Pages** available in for ordinary users +- ✅ `Docker` +- 🚀 `Deployment` + - `CI/CD` flow via `Render`
-![Django Dashboard Tabler - Open-Source Dashboard.](https://user-images.githubusercontent.com/51070104/202659663-fbb0ed51-677a-43fe-ad0b-13aaf5bd495b.png) +![Django Tabler - Open-Source Starter crafted by AppSeed.](https://github.com/app-generator/dummy/assets/51070104/8e56d253-5196-4a8d-961c-bd6c2a01a6a7)
-## ✨ Quick Start in `Docker` +## Start with `Docker` -> Get the code +> 👉 **Step 1** - Download the code from the GH repository (using `GIT`) ```bash $ git clone https://github.com/app-generator/django-tabler.git $ cd django-tabler ``` -> Start the app in Docker +
+ +> 👉 **Step 2** - Start the APP in `Docker` ```bash -$ docker-compose up --build +$ docker-compose up --build ``` -Visit `http://localhost:85` in your browser. The app should be up & running. +Visit `http://localhost:5085` in your browser. The app should be up & running.
-![Django Dashboard Tabler - Open-Source Web App.](https://raw.githubusercontent.com/app-generator/static/master/products/django-dashboard-tabler-screen.png) +## Environment + +Create a new `.env` file using sample `env.sample`. The meaning of each variable can be found below: + +- `DEBUG`: if `True` the app runs in develoment mode + - For production value `False` should be used +- For `MySql` persistence + - Install the DB Driver: `pip install mysqlclient` + - Create DB and assign a new user (full rights) + - Edit `.env` to match the DB, user, password ..
-## ✨ How to use it +## Manual Build + +> Download the code ```bash -$ # Get the code $ git clone https://github.com/app-generator/django-tabler.git $ cd django-tabler -$ -$ # Virtualenv modules installation (Unix based systems) +``` + +
+ +### 👉 Set Up for `Unix`, `MacOS` + +> Install modules via `VENV` + +```bash $ virtualenv env $ source env/bin/activate -$ -$ # Virtualenv modules installation (Windows based systems) -$ # virtualenv env -$ # .\env\Scripts\activate -$ -$ # Install modules -$ # SQLIte version $ pip3 install -r requirements.txt -$ -$ # Create tables -$ python manage.py makemigrations -$ python manage.py migrate -$ -$ # Start the application (development mode) -$ python manage.py runserver # default port 8000 -$ -$ # Start the app - custom port -$ # python manage.py runserver 0.0.0.0: -$ -$ # Access the web app in browser: http://127.0.0.1:8000/ ```
-## ✨ Code-base structure - -The project is coded using a simple and intuitive structure presented bellow: +> Set Up Database ```bash -< PROJECT ROOT > - | - |-- core/ # Implements app configuration - | |-- settings.py # Defines Global Settings - | |-- wsgi.py # Start the app in production - | |-- urls.py # Define URLs served by all apps/nodes - | - |-- apps/ - | | - | |-- home/ # A simple app that serve HTML files - | | |-- views.py # Serve HTML pages for authenticated users - | | |-- urls.py # Define some super simple routes - | | - | |-- authentication/ # Handles auth routes (login and register) - | | |-- urls.py # Define authentication routes - | | |-- views.py # Handles login and registration - | | |-- forms.py # Define auth forms (login and register) - | | - | |-- static/ - | | |-- # CSS files, Javascripts files - | | - | |-- templates/ # Templates used to render pages - | |-- includes/ # HTML chunks and components - | | |-- navigation.html # Top menu component - | | |-- sidebar.html # Sidebar component - | | |-- footer.html # App Footer - | | |-- scripts.html # Scripts common to all pages - | | - | |-- layouts/ # Master pages - | | |-- base-fullscreen.html # Used by Authentication pages - | | |-- base.html # Used by common pages - | | - | |-- accounts/ # Authentication pages - | | |-- login.html # Login page - | | |-- register.html # Register page - | | - | |-- home/ # UI Kit Pages - | |-- index.html # Index page - | |-- 404-page.html # 404 page - | |-- *.html # All other pages - | - |-- requirements.txt # Development modules - SQLite storage - | - |-- .env # Inject Configuration via Environment - |-- manage.py # Start the app - Django default start script - | - |-- ************************************************************************ +$ python manage.py makemigrations +$ python manage.py migrate ```
-> The bootstrap flow +> Start the APP -- Django bootstrapper `manage.py` uses `core/settings.py` as the main configuration file -- `core/settings.py` loads the app magic from `.env` file -- Redirect the guest users to Login page -- Unlock the pages served by *app* node for authenticated users +```bash +$ python manage.py createsuperuser # create the admin +$ python manage.py runserver # start the project +``` + +At this point, the app runs at `http://127.0.0.1:8000/`.
-## ✨ Deployment +### 👉 Set Up for `Windows` -The app is provided with a basic configuration to be executed in [Docker](https://www.docker.com/), [Gunicorn](https://gunicorn.org/), and [Waitress](https://docs.pylonsproject.org/projects/waitress/en/stable/). +> Install modules via `VENV` (windows) -### [Gunicorn](https://gunicorn.org/) ---- +``` +$ virtualenv env +$ .\env\Scripts\activate +$ pip3 install -r requirements.txt +``` -Gunicorn 'Green Unicorn' is a Python WSGI HTTP Server for UNIX. +
-> Install using pip +> Set Up Database ```bash -$ pip install gunicorn +$ python manage.py makemigrations +$ python manage.py migrate ``` -> Start the app using gunicorn binary + +
+ +> Start the APP ```bash -$ gunicorn --bind=0.0.0.0:8001 core.wsgi:application -Serving on http://localhost:8001 +$ python manage.py createsuperuser # create the admin +$ python manage.py runserver # start the project ``` -Visit `http://localhost:8001` in your browser. The app should be up & running. - +At this point, the app runs at `http://127.0.0.1:8000/`.
-### [Waitress](https://docs.pylonsproject.org/projects/waitress/en/stable/) ---- - -Waitress (Gunicorn equivalent for Windows) is meant to be a production-quality pure-Python WSGI server with very acceptable performance. It has no dependencies except ones that live in the Python standard library. +## Codebase Structure -> Install using pip +The project is coded using a simple and intuitive structure presented below: ```bash -$ pip install waitress +< PROJECT ROOT > + | + |-- core/ + | |-- settings.py # Project Configuration + | |-- urls.py # Project Routing + | + |-- home/ + | |-- views.py # APP Views + | |-- urls.py # APP Routing + | |-- models.py # APP Models + | |-- tests.py # Tests + | + |-- requirements.txt # Project Dependencies + | + |-- env.sample # ENV Configuration (default values) + |-- manage.py # Start the app - Django default start script + | + |-- ************************************************************************ ``` -> Start the app using [waitress-serve](https://docs.pylonsproject.org/projects/waitress/en/stable/runner.html) -```bash -$ waitress-serve --port=8001 core.wsgi:application -Serving on http://localhost:8001 -``` +
+ +## Deploy on [Render](https://render.com/) + +- Create a Blueprint instance + - Go to https://dashboard.render.com/blueprints this link. +- Click `New Blueprint Instance` button. +- Connect your `repo` which you want to deploy. +- Fill the `Service Group Name` and click on `Update Existing Resources` button. +- After that your deployment will start automatically. -Visit `http://localhost:8001` in your browser. The app should be up & running. +At this point, the product should be LIVE.
-## ✨ Credits & Links +## [PRO Version](https://appseed.us/product/volt-dashboard-pro/django/) + +This design is a pixel-perfect [Bootstrap 5](https://www.admin-dashboards.com/bootstrap-5-templates/) Dashboard with a fresh, new design. `Volt Dashboard PRO` is built with over 300 frontend individual elements, like buttons, inputs, navbars, nav tabs, cards, or alerts, giving you the freedom of choosing and combining. + +> Features: + +- `Up-to-date Dependencies` +- `Design`: [Django Theme Volt](https://github.com/app-generator/django-volt-dashboard-pro) - `PRO Version` +- `Sections` covered by the design: + - **Admin section** (reserved for superusers) + - **Authentication**: `Django.contrib.AUTH`, Registration + - **All Pages** available in for ordinary users +- `Docker`, `Deployment`: + - `CI/CD` flow via `Render` -- [Django](https://www.djangoproject.com/) - The official website -- [Boilerplate Code](https://appseed.us/boilerplate-code) - Index provided by **AppSeed** -- [Boilerplate Code](https://github.com/app-generator/boilerplate-code) - Index published on Github +![Volt Dashboard PRO - Starter generated by AppSeed.](https://user-images.githubusercontent.com/51070104/172672843-8c40a801-3438-4e9c-86db-38a34191fbdf.png)
--- -[Django Dashboard Tabler](https://appseed.us/admin-dashboards/django-dashboard-tabler) - Provided by **AppSeed [App Generator](https://appseed.us/app-generator)**. +[Django Dashboard Tabler](https://appseed.us/product/tabler/django/) - Open-source starter generated by **[AppSeed Generator](https://appseed.us/generator/)**. diff --git a/README_deploy.md b/README_deploy.md new file mode 100644 index 0000000..a1ac7e5 --- /dev/null +++ b/README_deploy.md @@ -0,0 +1,24 @@ +# How to deploy on `Render` + +> This document should contains all the steps to deploy the app on render without much effort, using PostgreSQL + +https://render.com/docs/deploy-django + +## ALL STEPS below + +
+ +### 👉 Create `PostgreSQL` database on render + - Go to https://dashboard.render.com/new/database this link. + - Database name should be `berry`. + - Keep the Database, User and Datadog API Key as it is. + - If you want to change database name anything else then you have to change your `render.yaml` file database name too. + +
+ +### 👉 Create a Blueprint instance + - Go to https://dashboard.render.com/blueprints this link. + - Click `New Blueprint Instance` button. + - Connect your `repo` which you want to deploy. + - Fill the `Service Group Name` and click on `Update Existing Resources` button. + - After that your deployment will start automatically. \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..475c139 --- /dev/null +++ b/build.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +# exit on error +set -o errexit + +python -m pip install --upgrade pip + +pip install -r requirements.txt + +python manage.py collectstatic --no-input +python manage.py migrate diff --git a/core/__init__.py b/core/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/core/asgi.py b/core/asgi.py new file mode 100644 index 0000000..26a5940 --- /dev/null +++ b/core/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for core 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/4.1/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings") + +application = get_asgi_application() diff --git a/core/settings.py b/core/settings.py new file mode 100644 index 0000000..b75ea59 --- /dev/null +++ b/core/settings.py @@ -0,0 +1,170 @@ +""" +Django settings for core project. + +Generated by 'django-admin startproject' using Django 4.1.2. + +For more information on this file, see +https://docs.djangoproject.com/en/4.1/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/4.1/ref/settings/ +""" + +import os, random, string +from pathlib import Path +from dotenv import load_dotenv + +load_dotenv() # take environment variables from .env. + +# 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.1/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = os.environ.get('SECRET_KEY') +if not SECRET_KEY: + SECRET_KEY = ''.join(random.choice( string.ascii_lowercase ) for i in range( 32 )) + +# Render Deployment Code +DEBUG = 'RENDER' not in os.environ + +# HOSTs List +ALLOWED_HOSTS = ['localhost', '127.0.0.1'] + +# Add here your deployment HOSTS +CSRF_TRUSTED_ORIGINS = ['http://localhost:8000', 'http://localhost:5085', 'http://127.0.0.1:8000', 'http://127.0.0.1:5085'] + +RENDER_EXTERNAL_HOSTNAME = os.environ.get('RENDER_EXTERNAL_HOSTNAME') +if RENDER_EXTERNAL_HOSTNAME: + ALLOWED_HOSTS.append(RENDER_EXTERNAL_HOSTNAME) + +# Application definition + +INSTALLED_APPS = [ + 'admin_tabler.apps.AdminTablerConfig', + "django.contrib.admin", + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.staticfiles", + + "home", +] + +MIDDLEWARE = [ + "django.middleware.security.SecurityMiddleware", + "whitenoise.middleware.WhiteNoiseMiddleware", + "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 = "core.urls" + +HOME_TEMPLATES = os.path.join(BASE_DIR, 'templates') + +TEMPLATES = [ + { + "BACKEND": "django.template.backends.django.DjangoTemplates", + "DIRS": [HOME_TEMPLATES], + "APP_DIRS": True, + "OPTIONS": { + "context_processors": [ + "django.template.context_processors.debug", + "django.template.context_processors.request", + "django.contrib.auth.context_processors.auth", + "django.contrib.messages.context_processors.messages", + ], + }, + }, +] + +WSGI_APPLICATION = "core.wsgi.application" + + +# Database +# https://docs.djangoproject.com/en/4.1/ref/settings/#databases + +DB_ENGINE = os.getenv('DB_ENGINE' , None) +DB_USERNAME = os.getenv('DB_USERNAME' , None) +DB_PASS = os.getenv('DB_PASS' , None) +DB_HOST = os.getenv('DB_HOST' , None) +DB_PORT = os.getenv('DB_PORT' , None) +DB_NAME = os.getenv('DB_NAME' , None) + +if DB_ENGINE and DB_NAME and DB_USERNAME: + DATABASES = { + 'default': { + 'ENGINE' : 'django.db.backends.' + DB_ENGINE, + 'NAME' : DB_NAME, + 'USER' : DB_USERNAME, + 'PASSWORD': DB_PASS, + 'HOST' : DB_HOST, + 'PORT' : DB_PORT, + }, + } +else: + DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': 'db.sqlite3', + } + } + +# Password validation +# https://docs.djangoproject.com/en/4.1/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/4.1/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/4.1/howto/static-files/ + +STATIC_URL = '/static/' +STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') + +STATICFILES_DIRS = ( + os.path.join(BASE_DIR, 'static'), +) + +#if not DEBUG: +# STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' + +# Default primary key field type +# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" + +LOGIN_REDIRECT_URL = '/' +EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' diff --git a/core/urls.py b/core/urls.py new file mode 100644 index 0000000..45201e3 --- /dev/null +++ b/core/urls.py @@ -0,0 +1,23 @@ +"""core URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/4.1/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 include, path + +urlpatterns = [ + path('', include('home.urls')), + path("admin/", admin.site.urls), + path('', include('admin_tabler.urls')), +] diff --git a/core/wsgi.py b/core/wsgi.py new file mode 100644 index 0000000..e9b9d8a --- /dev/null +++ b/core/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for core 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/4.1/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings") + +application = get_wsgi_application() diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d8a7514 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,27 @@ +version: '3.8' +services: + appseed-app: + container_name: appseed_app + restart: always + build: . + networks: + - db_network + - web_network + nginx: + container_name: nginx + restart: always + image: "nginx:latest" + ports: + - "5085:5085" + volumes: + - ./nginx:/etc/nginx/conf.d + networks: + - web_network + depends_on: + - appseed-app +networks: + db_network: + driver: bridge + web_network: + driver: bridge + \ No newline at end of file diff --git a/env.sample b/env.sample new file mode 100644 index 0000000..731756c --- /dev/null +++ b/env.sample @@ -0,0 +1,11 @@ +# True for development, False for production +DEBUG=True + +SECRET_KEY= + +# DB_ENGINE=mysql +# DB_HOST=localhost +# DB_NAME=appseed_db +# DB_USERNAME=appseed_db_usr +# DB_PASS=pass +# DB_PORT=3306 \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..c438205 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,59 @@ +/* + +========================================================= +* AppSeed - Simple SCSS compiler via Gulp +========================================================= + +*/ + +var autoprefixer = require('gulp-autoprefixer'); +var browserSync = require('browser-sync').create(); +var cleanCss = require('gulp-clean-css'); +var gulp = require('gulp'); +const npmDist = require('gulp-npm-dist'); +var sass = require('gulp-sass')(require('node-sass')); +var wait = require('gulp-wait'); +var sourcemaps = require('gulp-sourcemaps'); +var rename = require("gulp-rename"); + +// Define COMMON paths + +const paths = { + src: { + base: './static', + css: './static/css', + scss: './static/scss', + node_modules: './node_modules/', + vendor: './vendor' + } +}; + +// Compile SCSS +gulp.task('scss', function() { + return gulp.src([paths.src.scss + '/soft-ui-dashboard.scss']) + .pipe(wait(500)) + .pipe(sourcemaps.init()) + .pipe(sass().on('error', sass.logError)) + .pipe(autoprefixer({ + overrideBrowserslist: ['> 1%'] + })) + .pipe(sourcemaps.write('.')) + .pipe(gulp.dest(paths.src.css)) + .pipe(browserSync.stream()); +}); + +// Minify CSS +gulp.task('minify:css', function() { + return gulp.src([ + paths.src.css + '/soft-ui-dashboard.css' + ]) + .pipe(cleanCss()) + .pipe(rename(function(path) { + // Updates the object in-place + path.extname = ".min.css"; + })) + .pipe(gulp.dest(paths.src.css)) +}); + +// Default Task: Compile SCSS and minify the result +gulp.task('default', gulp.series('scss', 'minify:css')); diff --git a/gunicorn-cfg.py b/gunicorn-cfg.py new file mode 100644 index 0000000..3acce75 --- /dev/null +++ b/gunicorn-cfg.py @@ -0,0 +1,11 @@ +# -*- encoding: utf-8 -*- +""" +Copyright (c) 2019 - present AppSeed.us +""" + +bind = '0.0.0.0:5005' +workers = 1 +accesslog = '-' +loglevel = 'debug' +capture_output = True +enable_stdio_inheritance = True diff --git a/home/__init__.py b/home/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/home/admin.py b/home/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/home/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/home/apps.py b/home/apps.py new file mode 100644 index 0000000..e7d1c7e --- /dev/null +++ b/home/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class HomeConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "home" diff --git a/home/migrations/__init__.py b/home/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/home/models.py b/home/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/home/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/home/tests.py b/home/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/home/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/home/urls.py b/home/urls.py new file mode 100644 index 0000000..88a9cac --- /dev/null +++ b/home/urls.py @@ -0,0 +1,7 @@ +from django.urls import path + +from . import views + +urlpatterns = [ + path('', views.index, name='index'), +] diff --git a/home/views.py b/home/views.py new file mode 100644 index 0000000..a878981 --- /dev/null +++ b/home/views.py @@ -0,0 +1,9 @@ +from django.shortcuts import render +from django.http import HttpResponse + +# Create your views here. + +def index(request): + + # Page from the theme + return render(request, 'pages/index.html') diff --git a/manage.py b/manage.py new file mode 100644 index 0000000..4e20ce5 --- /dev/null +++ b/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", "core.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/nginx/appseed-app.conf b/nginx/appseed-app.conf new file mode 100644 index 0000000..61c7a1e --- /dev/null +++ b/nginx/appseed-app.conf @@ -0,0 +1,15 @@ +upstream webapp { + server appseed_app:5005; +} + +server { + listen 5085; + server_name localhost; + + location / { + proxy_pass http://webapp; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..5e076ea --- /dev/null +++ b/package.json @@ -0,0 +1,38 @@ +{ + "name": "appseed-generic", + "version": "1.0.0", + "description": "Generic tooling by AppSeed", + "main": "gulpfile.js", + "author": "AppSeed", + "keywords": [ + "css", + "sass", + "gulp", + "web" + ], + "homepage": "https://appseed.us", + "bugs": { + "email": "support@appseed.us" + }, + "license": "MIT License", + "devDependencies": { + "browser-sync": "^2.27.4", + "del": "^6.0.0", + "gulp": "^4.0.2", + "gulp-autoprefixer": "^8.0.0", + "gulp-clean-css": "^4.3.0", + "gulp-cssbeautify": "^3.0.0", + "node-sass": "^6.0.1", + "gulp-file-include": "^2.3.0", + "gulp-header": "^2.0.9", + "gulp-htmlmin": "^5.0.1", + "gulp-npm-dist": "^1.0.3", + "gulp-plumber": "^1.2.1", + "gulp-rename": "^2.0.0", + "gulp-sass": "^5.0.0", + "gulp-sourcemaps": "^3.0.0", + "gulp-uglify": "^3.0.2", + "gulp-wait": "^0.0.2", + "merge-stream": "^2.0.0" + } +} \ No newline at end of file diff --git a/render.yaml b/render.yaml new file mode 100644 index 0000000..8511b0a --- /dev/null +++ b/render.yaml @@ -0,0 +1,15 @@ +services: + - type: web + name: django-tabler + plan: starter + env: python + region: frankfurt # region should be same as your database region. + buildCommand: "./build.sh" + startCommand: "gunicorn core.wsgi:application" + envVars: + - key: DEBUG + value: False + - key: SECRET_KEY + generateValue: true + - key: WEB_CONCURRENCY + value: 4 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..9fec81b --- /dev/null +++ b/requirements.txt @@ -0,0 +1,8 @@ +django +gunicorn +python-dotenv +whitenoise +django-admin-tabler==1.0.2 + +# psycopg2-binary +# mysqlclient diff --git a/static/.gitkeep b/static/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/templates/.gitkeep b/templates/.gitkeep new file mode 100644 index 0000000..e69de29