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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,5 @@ htmlcov/
*.temp
.cache/


# Architecture
ARCHITECTURE.md
36 changes: 36 additions & 0 deletions api/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
venv/
env/
ENV/
.venv

# Testing
.pytest_cache/
.coverage
htmlcov/
*.log

# IDE
.vscode/
.idea/
*.swp
*.swo
*~

# OS
.DS_Store
Thumbs.db

# Project specific
*.md
.git/
.gitignore
tests/
pytest.ini
pyproject.toml
Comment thread
martian56 marked this conversation as resolved.

29 changes: 29 additions & 0 deletions api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM python:3.12-slim

WORKDIR /app

RUN apt-get update && apt-get install -y \
gcc \
postgresql-client \
&& rm -rf /var/lib/apt/lists/*

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Create non-root user
RUN useradd -m -u 1000 appuser

COPY . .

Comment thread
martian56 marked this conversation as resolved.
# Set ownership and permissions
RUN chown -R appuser:appuser /app && \
chmod +x /app/docker-entrypoint.sh

# Switch to non-root user
USER appuser

EXPOSE 8000

Comment thread
martian56 marked this conversation as resolved.
ENTRYPOINT ["/app/docker-entrypoint.sh"]
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
Comment thread
martian56 marked this conversation as resolved.

Comment thread
martian56 marked this conversation as resolved.
9 changes: 9 additions & 0 deletions api/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
set -e

echo "Running database migrations..."
alembic upgrade head

echo "Starting API server..."
exec "$@"

34 changes: 34 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
services:
api:
build:
context: ./api
dockerfile: Dockerfile
container_name: chatops-api
ports:
- "8000:8000"
environment:
- DATABASE_URL=postgresql://user:password@db:5432/chatops
- SECRET_KEY=your-secret-key-change-in-production
Comment thread
martian56 marked this conversation as resolved.
- 'CORS_ORIGINS=["http://localhost:5173","http://localhost:3000"]'
depends_on:
- db
Comment thread
martian56 marked this conversation as resolved.
volumes:
- ./api/.env:/app/.env # Mount .env file if it exists
restart: unless-stopped

db:
image: postgres:16-alpine
container_name: chatops-db
environment:
- POSTGRES_USER=user
- POSTGRES_PASSWORD=password
Comment thread
martian56 marked this conversation as resolved.
- POSTGRES_DB=chatops
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
restart: unless-stopped

volumes:
postgres_data: