initial backend development
This commit is contained in:
parent
9048691ce1
commit
74be830758
|
|
@ -0,0 +1,21 @@
|
|||
# Use official lightweight Python image
|
||||
FROM python:3.11-slim
|
||||
|
||||
# Set working directory inside container
|
||||
WORKDIR /app
|
||||
|
||||
# Install system dependencies
|
||||
RUN apt-get update && apt-get install -y gcc libpq-dev curl && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install Python dependencies
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Copy application code
|
||||
COPY . .
|
||||
|
||||
# Expose port for internal use (not mapped publicly unless via NGINX)
|
||||
EXPOSE 8000
|
||||
|
||||
# Run the FastAPI app with Uvicorn
|
||||
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
version: '3.8'
|
||||
|
||||
services:
|
||||
complycore-api:
|
||||
volumes:
|
||||
- ./backend:/app
|
||||
command: uvicorn main:app --host 0.0.0.0 --port 8000 --reload
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
from sqlalchemy import create_engine
|
||||
from dotenv import load_dotenv
|
||||
import os
|
||||
|
||||
# Load .env vars
|
||||
load_dotenv()
|
||||
|
||||
# Get env vars
|
||||
USER = os.getenv("user")
|
||||
PASSWORD = os.getenv("password")
|
||||
HOST = os.getenv("host")
|
||||
PORT = os.getenv("port")
|
||||
DBNAME = os.getenv("dbname")
|
||||
|
||||
# Full SQLAlchemy URI for Session Pooler
|
||||
DATABASE_URL = (
|
||||
f"postgresql+psycopg2://{USER}:{PASSWORD}@{HOST}:{PORT}/{DBNAME}?sslmode=require"
|
||||
)
|
||||
|
||||
# Use NullPool to defer to Supabase's pooler
|
||||
from sqlalchemy.pool import NullPool
|
||||
engine = create_engine(DATABASE_URL, poolclass=NullPool)
|
||||
|
||||
try:
|
||||
with engine.connect() as conn:
|
||||
print("✅ Supabase Session Pooler connection successful.")
|
||||
except Exception as e:
|
||||
print(f"❌ Connection failed: {e}")
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
fastapi==0.110.0
|
||||
uvicorn[standard]==0.27.1
|
||||
sqlalchemy==2.0.30
|
||||
psycopg2-binary==2.9.9
|
||||
python-dotenv==1.0.1
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
services:
|
||||
complycore-api:
|
||||
build:
|
||||
context: ./backend
|
||||
container_name: complycore-api
|
||||
restart: unless-stopped
|
||||
env_file:
|
||||
- ./backend/.env
|
||||
networks:
|
||||
- internal_only
|
||||
expose:
|
||||
- "8000"
|
||||
|
||||
|
||||
networks:
|
||||
internal_only:
|
||||
driver: bridge
|
||||
Loading…
Reference in New Issue