mirror of
https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git
synced 2025-08-14 00:25:46 +02:00
чиним билд13
This commit is contained in:
@@ -1,18 +1,17 @@
|
|||||||
"""Database connection module"""
|
"""Database configuration"""
|
||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
from sqlalchemy.ext.declarative import declarative_base
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
from sqlalchemy.orm import sessionmaker
|
from sqlalchemy.orm import sessionmaker
|
||||||
from .config import settings
|
import os
|
||||||
|
|
||||||
engine = create_engine(
|
SQLALCHEMY_DATABASE_URL = os.getenv(
|
||||||
settings.database_url,
|
"DATABASE_URL",
|
||||||
pool_size=5,
|
"postgresql://postgres:postgres@postgres/support_db"
|
||||||
max_overflow=10,
|
|
||||||
pool_timeout=30,
|
|
||||||
pool_recycle=1800
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
engine = create_engine(SQLALCHEMY_DATABASE_URL)
|
||||||
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
||||||
|
|
||||||
Base = declarative_base()
|
Base = declarative_base()
|
||||||
|
|
||||||
def get_db():
|
def get_db():
|
||||||
|
|||||||
8
backend/docker/postgres/init.sql
Normal file
8
backend/docker/postgres/init.sql
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
-- Create the postgres superuser
|
||||||
|
CREATE USER postgres WITH PASSWORD 'postgres' SUPERUSER;
|
||||||
|
|
||||||
|
-- Create the database
|
||||||
|
CREATE DATABASE support_db;
|
||||||
|
|
||||||
|
-- Grant privileges
|
||||||
|
GRANT ALL PRIVILEGES ON DATABASE support_db TO postgres;
|
||||||
@@ -1,56 +1,45 @@
|
|||||||
services:
|
version: '3.8'
|
||||||
postgres:
|
|
||||||
image: postgres:15-alpine
|
|
||||||
container_name: support-postgres
|
|
||||||
environment:
|
|
||||||
POSTGRES_DB: support_db
|
|
||||||
POSTGRES_USER: support_user
|
|
||||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
|
||||||
volumes:
|
|
||||||
- postgres_data:/var/lib/postgresql/data
|
|
||||||
ports:
|
|
||||||
- "5432:5432"
|
|
||||||
networks:
|
|
||||||
- app-network
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD-SHELL", "pg_isready -U support_user -d support_db"]
|
|
||||||
interval: 10s
|
|
||||||
timeout: 5s
|
|
||||||
retries: 5
|
|
||||||
|
|
||||||
|
services:
|
||||||
frontend:
|
frontend:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: ./frontend
|
||||||
dockerfile: docker/frontend/Dockerfile
|
dockerfile: Dockerfile
|
||||||
container_name: support-frontend
|
container_name: support-frontend
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "80:80"
|
||||||
networks:
|
|
||||||
- app-network
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- backend
|
- backend
|
||||||
|
networks:
|
||||||
|
- support-network
|
||||||
|
|
||||||
backend:
|
backend:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: ./backend
|
||||||
dockerfile: docker/backend/Dockerfile
|
dockerfile: Dockerfile
|
||||||
container_name: support-backend
|
container_name: support-backend
|
||||||
environment:
|
environment:
|
||||||
- DATABASE_URL=postgresql://support_user:${POSTGRES_PASSWORD}@postgres:5432/support_db
|
- DATABASE_URL=postgresql://postgres:postgres@postgres/support_db
|
||||||
ports:
|
|
||||||
- "8000:8000"
|
|
||||||
volumes:
|
|
||||||
- ./backend:/app
|
|
||||||
- ./logs:/app/logs:rw
|
|
||||||
networks:
|
|
||||||
- app-network
|
|
||||||
depends_on:
|
depends_on:
|
||||||
postgres:
|
- postgres
|
||||||
condition: service_healthy
|
networks:
|
||||||
restart: unless-stopped
|
- support-network
|
||||||
|
|
||||||
|
postgres:
|
||||||
|
image: postgres:15
|
||||||
|
container_name: support-postgres
|
||||||
|
environment:
|
||||||
|
- POSTGRES_USER=postgres
|
||||||
|
- POSTGRES_PASSWORD=postgres
|
||||||
|
- POSTGRES_DB=support_db
|
||||||
|
volumes:
|
||||||
|
- postgres_data:/var/lib/postgresql/data
|
||||||
|
- ./backend/docker/postgres/init.sql:/docker-entrypoint-initdb.d/init.sql
|
||||||
|
networks:
|
||||||
|
- support-network
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
app-network:
|
support-network:
|
||||||
driver: bridge
|
driver: bridge
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
|
|||||||
Reference in New Issue
Block a user