refactor: update docker volume mapping, add collectstatic to startup command, and normalize settings.py formatting

This commit is contained in:
2026-04-05 11:40:54 -03:00
parent 405033d1bf
commit 47821c4f71
2 changed files with 87 additions and 88 deletions

View File

@@ -13,9 +13,9 @@ services:
- ALLOWED_HOSTS=* - ALLOWED_HOSTS=*
volumes: volumes:
- /DATA/AppData/rrbec-api-django/data:/app/data - /DATA/AppData/rrbec-api-django:/app
- /DATA/AppData/rrbec-api-django/media:/app/media - /DATA/AppData/rrbec-api-django/static:/app/static
- /DATA/AppData/rrbec-api-django/static:/app/staticfiles - /DATA/AppData/rrbec-api-django/db:/app/db
working_dir: /app working_dir: /app
command: ["/bin/sh", "-c", "apt-get update && apt-get install -y git && rm -rf app_clone && git clone --branch api --depth 1 https://github.com/welton89/RRBEC.git app_clone && cp -r app_clone/* . && rm -rf app_clone && pip install -r requirements.txt && python manage.py migrate --noinput && gunicorn gestaoRaul.wsgi:application --bind 0.0.0.0:8000"] command: ["/bin/sh", "-c", "apt-get update && apt-get install -y git && rm -rf app_clone && git clone --branch api --depth 1 https://github.com/welton89/RRBEC.git app_clone && cp -r app_clone/* . && rm -rf app_clone && pip install -r requirements.txt && python manage.py collectstatic --noinput && python manage.py migrate --noinput && gunicorn gestaoRaul.wsgi:application --bind 0.0.0.0:8000"]

View File

@@ -17,12 +17,12 @@ from dotenv import load_dotenv
load_dotenv() load_dotenv()
DB_ENGINE = os.getenv('DB_ENGINE') DB_ENGINE = os.getenv("DB_ENGINE")
DB_HOST = os.getenv('DB_HOST') DB_HOST = os.getenv("DB_HOST")
DB_PORT = os.getenv('DB_PORT') DB_PORT = os.getenv("DB_PORT")
DB_NAME = os.getenv('DB_NAME') DB_NAME = os.getenv("DB_NAME")
DB_USER = os.getenv('DB_USER') DB_USER = os.getenv("DB_USER")
DB_PASSWORD = os.getenv('DB_PASSWORD') DB_PASSWORD = os.getenv("DB_PASSWORD")
# Build paths inside the project like this: BASE_DIR / 'subdir'. # Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent BASE_DIR = Path(__file__).resolve().parent.parent
@@ -32,82 +32,88 @@ BASE_DIR = Path(__file__).resolve().parent.parent
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret! # SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.getenv('SECRET_KEY', 'django-insecure-mqcnrs5!hc6bj$&#0@@9d8^2@x#w&$qhk3vlr5_)3znd9h6&d8') SECRET_KEY = os.getenv(
"SECRET_KEY", "django-insecure-mqcnrs5!hc6bj$&#0@@9d8^2@x#w&$qhk3vlr5_)3znd9h6&d8"
)
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = os.getenv('DEBUG', 'True') == 'True' DEBUG = os.getenv("DEBUG", "True") == "True"
ALLOWED_HOSTS = ['*'] ALLOWED_HOSTS = ["*"]
# Application definition # Application definition
INSTALLED_APPS = [ INSTALLED_APPS = [
'django.contrib.admin', "django.contrib.admin",
'django.contrib.auth', "django.contrib.auth",
'django.contrib.contenttypes', "django.contrib.contenttypes",
'django.contrib.sessions', "django.contrib.sessions",
'django.contrib.messages', "django.contrib.messages",
'django.contrib.staticfiles', "django.contrib.staticfiles",
'products', "products",
'mesas', "mesas",
'typePay', "typePay",
'clients', "clients",
'comandas', "comandas",
'categories', "categories",
'home', "home",
'payments', "payments",
'balcao', "balcao",
'orders', "orders",
'login', "login",
'sync', "sync",
'django_extensions', "django_extensions",
'pwa', "pwa",
'rest_framework', "rest_framework",
'corsheaders', "corsheaders",
] ]
MIDDLEWARE = [ MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware', "corsheaders.middleware.CorsMiddleware",
'django.middleware.security.SecurityMiddleware', "django.middleware.security.SecurityMiddleware",
'whitenoise.middleware.WhiteNoiseMiddleware', "whitenoise.middleware.WhiteNoiseMiddleware",
'django.contrib.sessions.middleware.SessionMiddleware', "django.contrib.sessions.middleware.SessionMiddleware",
'django.middleware.common.CommonMiddleware', "django.middleware.common.CommonMiddleware",
'django.middleware.csrf.CsrfViewMiddleware', "django.middleware.csrf.CsrfViewMiddleware",
'django.contrib.auth.middleware.AuthenticationMiddleware', "django.contrib.auth.middleware.AuthenticationMiddleware",
'django.contrib.messages.middleware.MessageMiddleware', "django.contrib.messages.middleware.MessageMiddleware",
'django.middleware.clickjacking.XFrameOptionsMiddleware', "django.middleware.clickjacking.XFrameOptionsMiddleware",
] ]
ROOT_URLCONF = 'gestaoRaul.urls' ROOT_URLCONF = "gestaoRaul.urls"
TEMPLATES = [ TEMPLATES = [
{ {
'BACKEND': 'django.template.backends.django.DjangoTemplates', "BACKEND": "django.template.backends.django.DjangoTemplates",
'DIRS': [os.path.join(BASE_DIR, 'templates'),], "DIRS": [
'APP_DIRS': True, os.path.join(BASE_DIR, "templates"),
'OPTIONS': { ],
'context_processors': [ "APP_DIRS": True,
'django.template.context_processors.debug', "OPTIONS": {
'django.template.context_processors.request', "context_processors": [
'django.contrib.auth.context_processors.auth', "django.template.context_processors.debug",
'django.contrib.messages.context_processors.messages', "django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
], ],
}, },
}, },
] ]
WSGI_APPLICATION = 'gestaoRaul.wsgi.application' WSGI_APPLICATION = "gestaoRaul.wsgi.application"
# Database # Database
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases # https://docs.djangoproject.com/en/5.1/ref/settings/#databases
import os
DATABASES = { DATABASES = {
'default': { "default": {
'ENGINE': 'django.db.backends.sqlite3', "ENGINE": "django.db.backends.sqlite3",
'NAME': BASE_DIR / 'db.sqlite3', "NAME": os.path.join(BASE_DIR, "db", "db.sqlite3"),
} }
} }
@@ -128,16 +134,16 @@ DATABASES = {
AUTH_PASSWORD_VALIDATORS = [ AUTH_PASSWORD_VALIDATORS = [
{ {
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
}, },
{ {
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
}, },
{ {
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
}, },
{ {
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
}, },
] ]
@@ -145,22 +151,22 @@ AUTH_PASSWORD_VALIDATORS = [
# Internationalization # Internationalization
# https://docs.djangoproject.com/en/5.1/topics/i18n/ # https://docs.djangoproject.com/en/5.1/topics/i18n/
LANGUAGE_CODE = 'pt-BR' LANGUAGE_CODE = "pt-BR"
TIME_ZONE = 'America/Sao_Paulo' TIME_ZONE = "America/Sao_Paulo"
USE_I18N = True USE_I18N = True
USE_TZ = True USE_TZ = True
DATE_FORMAT = 'd/m/Y - H:M' DATE_FORMAT = "d/m/Y - H:M"
# Static files (CSS, JavaScript, Images) # Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/5.1/howto/static-files/ # https://docs.djangoproject.com/en/5.1/howto/static-files/
STATIC_URL = 'static/' STATIC_URL = "static/"
STATICFILES_DIRS = (os.path.join(BASE_DIR, 'templates/static'),) STATICFILES_DIRS = (os.path.join(BASE_DIR, "templates/static"),)
STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATIC_ROOT = os.path.join(BASE_DIR, "static")
# WhiteNoise storage to compress and cache static files # WhiteNoise storage to compress and cache static files
STORAGES = { STORAGES = {
@@ -172,14 +178,13 @@ STORAGES = {
}, },
} }
MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_ROOT = os.path.join(BASE_DIR, "media")
MEDIA_URL = '/media/' MEDIA_URL = "/media/"
# Default primary key field type # Default primary key field type
# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field # https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
# pwa.py # pwa.py
@@ -194,16 +199,12 @@ PWA_APP_DISPLAY = "standalone"
PWA_APP_ORIENTATION = "any" PWA_APP_ORIENTATION = "any"
PWA_APP_START_URL = "/" PWA_APP_START_URL = "/"
PWA_APP_ICONS = [ PWA_APP_ICONS = [
{ {"src": "/static/midia/logo.png", "sizes": "160x160", "type": "image/png"},
"src": "/static/midia/logo.png",
"sizes": "160x160",
"type": "image/png"
},
# ... adicione outros tamanhos de ícones # ... adicione outros tamanhos de ícones
] ]
PWA_APP_SPLASH_SCREEN = { PWA_APP_SPLASH_SCREEN = {
"src": "/static/midia/logo.png", "src": "/static/midia/logo.png",
"media": "(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2)" "media": "(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2)",
} }
PWA_APP_DIR = "ltr" PWA_APP_DIR = "ltr"
PWA_APP_LANG = "pt-BR" PWA_APP_LANG = "pt-BR"
@@ -213,16 +214,14 @@ CORS_ALLOW_ALL_ORIGINS = True # Para desenvolvimento
CORS_ALLOW_CREDENTIALS = True # Permite envio de cookies para SessionAuth CORS_ALLOW_CREDENTIALS = True # Permite envio de cookies para SessionAuth
REST_FRAMEWORK = { REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': ( "DEFAULT_AUTHENTICATION_CLASSES": (
'rest_framework.authentication.SessionAuthentication', # Prioridade para teste no navegador "rest_framework.authentication.SessionAuthentication", # Prioridade para teste no navegador
'rest_framework_simplejwt.authentication.JWTAuthentication', "rest_framework_simplejwt.authentication.JWTAuthentication",
),
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticated',
), ),
"DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.IsAuthenticated",),
} }
SIMPLE_JWT = { SIMPLE_JWT = {
'ACCESS_TOKEN_LIFETIME': timedelta(minutes=60), "ACCESS_TOKEN_LIFETIME": timedelta(minutes=60),
'REFRESH_TOKEN_LIFETIME': timedelta(days=1), "REFRESH_TOKEN_LIFETIME": timedelta(days=1),
} }