Initial commit
This commit is contained in:
43
docker/Dockerfile.backend
Normal file
43
docker/Dockerfile.backend
Normal file
@@ -0,0 +1,43 @@
|
||||
# FastAPI Backend Dockerfile
|
||||
FROM python:3.11-slim
|
||||
|
||||
# Instalar dependencias del sistema
|
||||
RUN apt-get update && apt-get install -y \
|
||||
gcc \
|
||||
libpq-dev \
|
||||
curl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Configurar directorio de trabajo
|
||||
WORKDIR /app
|
||||
|
||||
# Copiar requirements y instalar dependencias Python
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Crear usuario no root
|
||||
RUN useradd --create-home --shell /bin/bash app \
|
||||
&& chown -R app:app /app
|
||||
|
||||
# Crear directorios necesarios
|
||||
RUN mkdir -p /app/uploads /app/logs \
|
||||
&& chown -R app:app /app/uploads /app/logs
|
||||
|
||||
# Copiar código de la aplicación
|
||||
COPY . .
|
||||
|
||||
# Cambiar permisos
|
||||
RUN chown -R app:app /app
|
||||
|
||||
# Cambiar a usuario no root
|
||||
USER app
|
||||
|
||||
# Exponer puerto
|
||||
EXPOSE 8000
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
|
||||
CMD curl -f http://localhost:8000/health || exit 1
|
||||
|
||||
# Comando por defecto
|
||||
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
|
||||
Reference in New Issue
Block a user