Add initial Docker and Alembic setup

Introduce a `docker-compose.yml` to define the services for backend and database with health checks. Add Alembic configurations for database migrations and an initial empty migration. Include backend-related Docker setup with an entrypoint script for database migration execution.
This commit is contained in:
2025-02-27 12:50:44 +01:00
parent 1d00b092fd
commit 3f1e1320f2
9 changed files with 266 additions and 0 deletions

37
backend/Dockerfile Normal file
View File

@@ -0,0 +1,37 @@
# Use Python 3.12 as the base image
FROM python:3.12-slim
# Set working directory
WORKDIR /app
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=/app
# Install system dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends gcc postgresql-client \
&& apt-get clean \
&& 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 . .
# Set up entrypoint script
# Note: entrypoint.sh is at the root of the backend directory, not in a scripts folder
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
# Expose port
EXPOSE 8000
# Set the entrypoint
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
# Default command
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]