Compare commits

..

No commits in common. "ca73d6ca795e783219d1d54fc126283dab0fd3d0" and "d7bd69f68c8cca3ba3484cf0ab78d8daa0db779e" have entirely different histories.

2 changed files with 43 additions and 76 deletions

View File

@ -1,55 +1,30 @@
# Git
# Git files
.git
.gitignore
# Python
# Virtual environment
.venv
venv/
env/
ENV/
*.env # Ignore local .env files within the backend directory if any
# Python cache
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# Virtual Environment
venv/
ENV/
# IDE
# IDE files
.idea/
.vscode/
*.swp
*.swo
# Logs
*.log
# Local development
.env
.env.local
.env.*.local
# Docker
Dockerfile*
docker-compose*
.dockerignore
# Tests
tests/
test/
# Test artifacts
.pytest_cache/
.coverage
htmlcov/
.coverage*
# Other build/temp files
*.egg-info/
dist/
build/
*.db # e.g., sqlite temp dbs

View File

@ -1,43 +1,35 @@
# be/Dockerfile
# Use multi-stage build
FROM python:alpine AS builder
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
# Install build dependencies
RUN apk add --no-cache \
gcc \
musl-dev \
postgresql-dev
# Create and activate virtual environment
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Final stage
# Choose a suitable Python base image
FROM python:alpine
# Copy virtual environment from builder
COPY --from=builder /opt/venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1 # Prevent python from writing pyc files
ENV PYTHONUNBUFFERED 1 # Keep stdout/stderr unbuffered
# Set working directory
# Set the working directory in the container
WORKDIR /app
# Copy application code
COPY . .
# Install system dependencies if needed (e.g., for psycopg2 build)
# RUN apt-get update && apt-get install -y --no-install-recommends gcc build-essential libpq-dev && rm -rf /var/lib/apt/lists/*
# Expose port
# Install Python dependencies
# Upgrade pip first
RUN pip install --no-cache-dir --upgrade pip
# Copy only requirements first to leverage Docker cache
COPY requirements.txt requirements.txt
# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application code into the working directory
COPY . .
# This includes your 'app/' directory, alembic.ini, etc.
# Expose the port the app runs on
EXPOSE 8000
# Run the application
# Command to run the application using uvicorn
# The default command for production (can be overridden in docker-compose for development)
# Note: Make sure 'app.main:app' correctly points to your FastAPI app instance
# relative to the WORKDIR (/app). If your main.py is directly in /app, this is correct.
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]