mitlist/be/Dockerfile
mohamad 8ff31ecf91 refactor: Update deployment workflows and Dockerfiles for production
- Modified the GitHub Actions workflow to streamline the deployment process by installing Docker directly and using shell commands for building and pushing images.
- Changed the base image for the backend Dockerfile from `python:3.11-slim` to `python:alpine` for a smaller footprint.
- Updated the frontend Dockerfile to use `node:23-alpine` instead of `node:24-alpine`, and refactored the production stage to use `node:slim`. Added a script for runtime environment variable injection.
2025-06-01 14:37:09 +02:00

35 lines
1.3 KiB
Docker

# be/Dockerfile
# Choose a suitable Python base image
FROM python:alpine
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1 # Prevent python from writing pyc files
ENV PYTHONUNBUFFERED 1 # Keep stdout/stderr unbuffered
# Set the working directory in the container
WORKDIR /app
# 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/*
# 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
# 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"]