add env and clean old apps

add env and clean old apps
This commit is contained in:
jnfire 2022-07-29 10:59:09 +02:00
parent 400d0f1b9c
commit e51406e31a
20 changed files with 177 additions and 132 deletions

View File

@ -1,4 +1,4 @@
http://ccstech.localhost
{$DOMAIN_URL}
root * /usr/src/app/

View File

@ -19,6 +19,7 @@ RUN apt install -y build-essential python3-dev libpq-dev python3-pip gettext
# install dependencies
RUN pip3 install --upgrade pip
# install basic dependencies
COPY ./requirements.txt .
RUN pip3 install -r requirements.txt

View File

@ -1,3 +0,0 @@
from django.contrib import admin
# Register your models here.

View File

@ -1,6 +0,0 @@
from django.apps import AppConfig
class WebsiteConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'app.website'

View File

@ -1,3 +0,0 @@
from django.db import models
# Create your models here.

View File

@ -1 +0,0 @@
<h1>Hi</h1>

View File

@ -1,3 +0,0 @@
from django.test import TestCase
# Create your tests here.

View File

@ -1,5 +0,0 @@
from django.shortcuts import render
# Create your views here.
def home(request):
return render(request, 'home.html')

View File

View File

@ -1,16 +0,0 @@
"""
WSGI config for ccstech 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.0/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ccstech.settings')
application = get_wsgi_application()

View File

@ -42,7 +42,7 @@ INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
'django_extensions',
'app.website',
'rest_framework',
]
MIDDLEWARE = [
@ -55,7 +55,7 @@ MIDDLEWARE = [
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'ccstech.urls'
ROOT_URLCONF = 'core.urls'
TEMPLATES = [
{

View File

@ -12,6 +12,6 @@ python3 manage.py migrate
# Start server
echo "Starting server"
## With WebSockets
uvicorn --host 0.0.0.0 --port 8000 --reload ccstech.asgi:application
## without WebSockets
#gunicorn --workers=4 -b 0.0.0.0:8000 --reload ccstech.wsgi:application
python3 manage.py runserver 0.0.0.0:8000
#echo "*****Start server with production mode*****"
#daphne -b 0.0.0.0 -p 8000 core.asgi:application

82
docker-compose.dev.yaml Normal file
View File

@ -0,0 +1,82 @@
version: '3.8'
services:
postgresql:
image: postgres
container_name: ${PROJECT_NAME}-postgresql
restart: "no"
environment:
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_DB: ${DB_NAME}
ports:
- ${DB_PORT}:5432
django:
build:
context: ./
dockerfile: ./Dockerfiles/django/Dockerfile
container_name: ${PROJECT_NAME}-django
restart: "no"
entrypoint: /django-launcher.sh
volumes:
- .:/usr/src/app/
environment:
DEBUG: "False"
ALLOWED_HOSTS: ${DOMAIN}
SECRET_KEY: ${DJANGO_SECRET_KEY}
DB_ENGINE: django.db.backends.postgresql
DB_NAME: ${DB_NAME}
DB_USER: ${DB_USER}
DB_PASSWORD: ${DB_PASSWORD}
DB_HOST: ${DB_HOST}
DB_PORT: ${DB_PORT}
DOMAIN: ${DOMAIN}
DOMAIN_URL: ${DOMAIN_URL}
STATIC_URL: /static/
STATIC_ROOT: static
MEDIA_URL: /media/
REDIS_HOST: ${REDIS_HOST}
REDIS_PORT: ${REDIS_PORT}
EMAIL_HOST: ${EMAIL_HOST}
EMAIL_USE_TLS: ${EMAIL_USE_TLS}
EMAIL_USE_SSL: ${EMAIL_USE_SSL}
EMAIL_PORT: ${EMAIL_PORT}
EMAIL_USER: ${EMAIL_USER}
EMAIL_PASSWORD: ${EMAIL_PASSWORD}
expose:
- 8000
depends_on:
- postgresql
links:
- redis
caddy:
image: caddy:alpine
container_name: ${PROJECT_NAME}-caddy
restart: "no"
ports:
- ${CADDY_PORT_ONE}:80
- ${CADDY_PORT_TWO}:443
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- ./caddy_data:/data
- .:/usr/src/app/
depends_on:
- django
redis:
image: redis:alpine
container_name: ${PROJECT_NAME}-redis
restart: "no"
expose:
- ${REDIS_PORT}
mailhog:
image: mailhog/mailhog:latest
restart: "no"
expose:
- 1025
ports:
- ${MAILHOG_PORT}:8025

74
docker-compose.pro.yaml Normal file
View File

@ -0,0 +1,74 @@
version: '3.8'
services:
postgresql:
image: postgres
container_name: ${PROJECT_NAME}-postgresql
restart: always
environment:
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_DB: ${DB_NAME}
ports:
- ${DB_PORT}:5432
django:
build:
context: ./
dockerfile: ./Dockerfiles/django/Dockerfile
container_name: ${PROJECT_NAME}-django
restart: always
entrypoint: /django-launcher.sh
volumes:
- .:/usr/src/app/
environment:
DEBUG: "False"
ALLOWED_HOSTS: ${DOMAIN}
SECRET_KEY: ${DJANGO_SECRET_KEY}
DB_ENGINE: django.db.backends.postgresql
DB_NAME: ${DB_NAME}
DB_USER: ${DB_USER}
DB_PASSWORD: ${DB_PASSWORD}
DB_HOST: ${DB_HOST}
DB_PORT: ${DB_PORT}
DOMAIN: ${DOMAIN}
DOMAIN_URL: ${DOMAIN_URL}
STATIC_URL: /static/
STATIC_ROOT: static
MEDIA_URL: /media/
REDIS_HOST: ${REDIS_HOST}
REDIS_PORT: ${REDIS_PORT}
EMAIL_HOST: ${EMAIL_HOST}
EMAIL_USE_TLS: ${EMAIL_USE_TLS}
EMAIL_USE_SSL: ${EMAIL_USE_SSL}
EMAIL_PORT: ${EMAIL_PORT}
EMAIL_USER: ${EMAIL_USER}
EMAIL_PASSWORD: ${EMAIL_PASSWORD}
expose:
- 8000
depends_on:
- postgresql
links:
- redis
caddy:
image: caddy:alpine
container_name: ${PROJECT_NAME}-caddy
restart: always
ports:
- ${CADDY_PORT_ONE}:80
- ${CADDY_PORT_TWO}:443
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- ./caddy_data:/data
- .:/usr/src/app/
depends_on:
- django
redis:
image: redis:alpine
container_name: ${PROJECT_NAME}-redis
restart: always
expose:
- ${REDIS_PORT}

View File

@ -1,75 +0,0 @@
version: '3.8'
services:
postgresql:
image: postgres
restart: "no"
environment:
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "postgres"
POSTGRES_DB: "ccstech"
ports:
- 5432:5432
django:
build:
context: ./
dockerfile: ./Dockerfiles/django/Dockerfile
restart: "no"
entrypoint: /django-launcher.sh
volumes:
- .:/usr/src/app/
environment:
DEBUG: "True"
ALLOWED_HOSTS: "ccstech.localhost"
SECRET_KEY: "misecreto"
DB_ENGINE: "django.db.backends.postgresql"
DB_NAME: "ccstech"
DB_USER: "postgres"
DB_PASSWORD: "postgres"
DB_HOST: "postgresql"
DB_PORT: "5432"
DOMAIN: "ccstech.localhost"
DOMAIN_URL: "http://ccstech.localhost"
STATIC_URL: "/static/"
STATIC_ROOT: "static"
MEDIA_URL: "/media/"
REDIS_HOST: "redis"
REDIS_PORT: "6379"
EMAIL_HOST: "mailhog"
EMAIL_USE_TLS: "False"
EMAIL_PORT: "1025"
EMAIL_USER: ""
EMAIL_PASSWORD: ""
expose:
- 8000
depends_on:
- postgresql
caddy:
image: caddy:alpine
restart: "no"
ports:
- 80:80
- 443:443
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- ./caddy_data:/data
- .:/usr/src/app/
depends_on:
- django
redis:
image: redis:alpine
restart: "no"
expose:
- 6379
mailhog:
image: mailhog/mailhog:latest
restart: "no"
expose:
- 1025
ports:
- 8025:8025

View File

@ -1,18 +1,18 @@
# Django
django===4.0.5
django-extensions===3.1.5
django===4.0.6
django-extensions===3.2.0
# PostgreSQL driver
psycopg2-binary===2.9.3
# Servidor para Django sin Websockets
gunicorn===20.1.0
# Servidor para Django con Websockets
uvicorn===0.18.1
websockets===10.3
# Channels
channels==3.0.5
# Check connection
redis==4.3.4
# Django Server
daphne===3.0.2
asgiref===3.5.2
# Conector de Redis para Channels
channels_redis===3.4.0
# Template
# Pillow
Pillow===9.1.1
# Templates
## Image processing
Pillow===9.2.0
# Testing
pytest==7.1.2
pytest-django==4.5.2