Setup production env

This commit is contained in:
IRBorisov 2023-08-08 15:33:23 +03:00
parent 6e81c13be5
commit a4c31efdb6
8 changed files with 112 additions and 7 deletions

2
.gitignore vendored
View File

@ -1,5 +1,5 @@
# SECURITY SENSITIVE FILES
# persistent/*
secrets/
# External distributions
rsconcept/backend/import/*.whl

View File

@ -1,5 +1,3 @@
version: "3.9"
volumes:
postgres_volume:
name: "postgres-db"

80
docker-compose-prod.yml Normal file
View File

@ -0,0 +1,80 @@
volumes:
postgres_volume:
name: "portal-db"
django_static_volume:
name: "portal-static"
django_media_volume:
name: "portal-media"
networks:
default:
name: concept-api-net
secrets:
django_key:
file: ./secrets/django_key.txt
db_password:
file: ./secrets/db_password.txt
services:
frontend:
restart: always
container_name: "portal-front"
depends_on:
- backend
build:
context: ./rsconcept/frontend
ports:
- 3000:3000
command: serve -s /home/node -l 3000
backend:
restart: always
container_name: "portal-back"
depends_on:
- postgresql-db
- nginx
secrets:
- db_password
- django_key
build:
context: ./rsconcept/backend
env_file: ./rsconcept/backend/.env.prod
environment:
SECRET_KEY: /run/secrets/django_key
DB_PASSWORD: /run/secrets/db_password
ports:
- 8000:8000
volumes:
- django_static_volume:/home/app/web/static
- django_media_volume:/home/app/web/media
command:
gunicorn -w 3 project.wsgi --bind 0.0.0.0:8000
postgresql-db:
restart: always
container_name: "portal-db"
image: postgres:alpine
secrets:
- db_password
env_file: ./postgresql/.env.prod
environment:
POSTGRES_PASSWORD: /run/secrets/db_password
volumes:
- postgres_volume:/var/lib/postgresql/data
nginx:
restart: always
container_name: "portal-nginx"
build:
context: ./nginx
ports:
- 1337:80
command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"
volumes:
- django_static_volume:/var/www/static
- django_media_volume:/var/www/media

View File

@ -6,7 +6,7 @@ upstream innerdjango {
server {
listen 80;
server_name rs.acconcept.ru;
server_name portal.acconcept.ru;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;

2
postgresql/.env.prod Normal file
View File

@ -0,0 +1,2 @@
POSTGRES_USER=portal-admin
POSTGRES_DB=portal-db

View File

@ -4,8 +4,8 @@
# Application settings
SECRET_KEY=django-insecure-)rq@!&v7l2r%2%q#n!uq+zk@=&yc0^&ql^7%2!%9u)vt1x&j=d
ALLOWED_HOSTS=rs.acconcept.ru;localhost;portal.acconcept.ru
CSRF_TRUSTED_ORIGINS=http://rs.acconcept.ru:3000;http://localhost:3000;http://portal.acconcept.ru:3000
CORS_ALLOWED_ORIGINS=http://rs.acconcept.ru:3000;http://localhost:3000;http://portal.acconcept.ru:3000
CSRF_TRUSTED_ORIGINS=http://rs.acconcept.ru:3000;http://localhost:3000
CORS_ALLOWED_ORIGINS=http://rs.acconcept.ru:3000;http://localhost:3000
# File locations

View File

@ -0,0 +1,24 @@
# Application settings
ALLOWED_HOSTS=localhost;portal.acconcept.ru;dev.concept.ru
CSRF_TRUSTED_ORIGINS=http://dev.concept.ru:3000;http://localhost:3000;http://portal.acconcept.ru:3000
CORS_ALLOWED_ORIGINS=http://dev.concept.ru:3000;http://localhost:3000;http://portal.acconcept.ru:3000
# File locations
STATIC_ROOT=/home/app/web/static
MEDIA_ROOT=/home/app/web/media
# Database settings
DB_ENGINE=django.db.backends.postgresql_psycopg2
DB_NAME=portal-db
DB_USER=portal-admin
DB_HOST=postgresql-db
DB_PORT=5432
# Debug settings
DEBUG=0
PYTHONDEVMODE=0
PYTHONTRACEMALLOC=0

View File

@ -1,6 +1,7 @@
// Constants
const prod = {
backend: 'http://rs.acconcept.ru:8000',
// backend: 'http://dev.concept.ru:8000',
backend: 'http://localhost:8000',
};
const dev = {