Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.git
.github
.vscode
.venv
.uv-cache
.mypy_cache
.ruff_cache
.pytest_cache
__pycache__
*.pyc
*.pyo
*.pyd
*.db
*.sqlite3
.env
db/schema.sql
9 changes: 9 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ POSTGRES_USER=multi
POSTGRES_PASSWORD=multi_pass
POSTGRES_DB=multi_ai
POSTGRES_PORT=5432
POSTGRES_HOST=localhost

# =========================
# NATS
# =========================
NATS_PORT=4222
NATS_MONITOR_PORT=8222
NATS_HOST=localhost
NATS_USER=testuser
NATS_PASSWORD=testpassword

# =========================
# MinIO
Expand All @@ -19,6 +23,11 @@ MINIO_ROOT_USER=minio
MINIO_ROOT_PASSWORD=minio_pass
MINIO_API_PORT=9000
MINIO_CONSOLE_PORT=9001
MINIO_HOST=localhost

REDIS_PORT=6379
REDIS_HOST=localhost
REDIS_PASSWORD=

# =========================
# pgAdmin
Expand Down
44 changes: 44 additions & 0 deletions .env.staging.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# =========================
# PostgreSQL
# =========================
POSTGRES_USER=multi
POSTGRES_PASSWORD=multi_pass
POSTGRES_DB=multi_ai
POSTGRES_PORT=5432
POSTGRES_HOST=postgres

# =========================
# NATS
# =========================
NATS_PORT=4222
NATS_MONITOR_PORT=8222
NATS_HOST=nats
NATS_USER=testuser
NATS_PASSWORD=testpassword

# =========================
# MinIO
# =========================
MINIO_ROOT_USER=minio
MINIO_ROOT_PASSWORD=minio_pass
MINIO_API_PORT=9000
MINIO_CONSOLE_PORT=9001
MINIO_HOST=minio

# =========================
# Redis
# =========================
REDIS_PORT=6379
REDIS_HOST=redis

# =========================
# pgAdmin
# =========================
PGADMIN_PORT=5050

jwt_secret=super_secret_jwt_key
jwt_algorithm=HS256
encryption_key=super_secret_encryption_key
totp_issuer=MultiAI


3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.env
.env.staging
__pycache__
db/schema.sql
db/schema.sql
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

FROM python:3.12-slim

# Install PostgreSQL client libraries and build tools
RUN apt-get update \
&& apt-get install -y --no-install-recommends libpq-dev gcc \
&& rm -rf /var/lib/apt/lists/*

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add another dockerfile tht run the migration on postgress in the staging or do it in this dockerfile

WORKDIR /app

RUN pip install --no-cache-dir uv

COPY pyproject.toml uv.lock ./
RUN uv sync --locked --no-dev \
&& uv pip install alembic

COPY . .

EXPOSE 8000

CMD ["uv", "run", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
110 changes: 110 additions & 0 deletions docker-compose.staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
services:
postgres:
image: pgvector/pgvector:pg16
container_name: multi_postgres
restart: unless-stopped
env_file:
- .env.staging
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
ports:
- "${POSTGRES_PORT}:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- multi_network

nats:
image: nats:2.10-alpine
container_name: multi_nats
command: >
-js
-a 0.0.0.0
-m ${NATS_MONITOR_PORT}
--user ${NATS_USER}
--pass ${NATS_PASSWORD}
ports:
- "${NATS_PORT}:4222"
- "${NATS_MONITOR_PORT}:8222"
networks:
- multi_network

minio:
image: minio/minio:latest
container_name: multi_minio
restart: unless-stopped
env_file:
- .env.staging
command: server /data --console-address ":${MINIO_CONSOLE_PORT}"
ports:
- "${MINIO_API_PORT}:9000"
- "${MINIO_CONSOLE_PORT}:9001"
volumes:
- minio_data:/data
networks:
- multi_network

pgadmin:
image: dpage/pgadmin4
container_name: multi_pgadmin
restart: unless-stopped
environment:
PGADMIN_DEFAULT_EMAIL: admin@example.com
PGADMIN_DEFAULT_PASSWORD: admin
ports:
- "${PGADMIN_PORT}:80"
networks:
- multi_network

redis:
image: redis:7-alpine
container_name: multi_redis
restart: unless-stopped
ports:
- "${REDIS_PORT}:6379"
networks:
- multi_network
volumes:
- redis_data:/data

fastapi:
build:
context: .
dockerfile: Dockerfile
container_name: multi_fastapi
restart: unless-stopped
env_file:
- .env.staging
depends_on:
- postgres
- redis
- nats
- minio
ports:
- "8000:8000"
networks:
- multi_network

migrate:
build:
context: .
dockerfile: Dockerfile
container_name: multi_migrate
env_file:
- .env.staging
depends_on:
- postgres
command: ["uv", "run", "alembic", "upgrade", "head"]
networks:
- multi_network

volumes:
postgres_data:
minio_data:
redis_data:

networks:
multi_network:
driver: bridge
14 changes: 6 additions & 8 deletions docker-compose.yml

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create env for staging tht have the hosts of staging network (instead of local host we use service name ) and sone touch the .env we let it for the dev environement

Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
version: "3.9"

services:

postgres:
image: pgvector/pgvector:pg16
container_name: multi_postgres
Expand All @@ -13,7 +10,7 @@ services:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
ports:
- "${POSTGRES_PORT}:5432"
- "${POSTGRES_PORT}:5432"

volumes:
- postgres_data:/var/lib/postgresql/data
Expand All @@ -27,6 +24,8 @@ services:
-js
-a 0.0.0.0
-m ${NATS_MONITOR_PORT}
--user ${NATS_USER}
--pass ${NATS_PASSWORD}
ports:
- "${NATS_PORT}:4222"
- "${NATS_MONITOR_PORT}:8222"
Expand Down Expand Up @@ -59,7 +58,7 @@ services:
- "${PGADMIN_PORT}:80"
networks:
- multi_network

redis:
image: redis:7-alpine
container_name: multi_redis
Expand All @@ -69,14 +68,13 @@ services:
networks:
- multi_network
volumes:
- redis_data:/data
- redis_data:/data

volumes:
postgres_data:
minio_data:
redis_data:


networks:
multi_network:
driver: bridge
driver: bridge