Skip to content

Commit

Permalink
Modifico Dockerfile para mejores practicas
Browse files Browse the repository at this point in the history
  • Loading branch information
GonzaloEBaez committed Jun 15, 2024
1 parent 933388f commit 651b940
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
# Utilizamos una imagen base adecuada para nuestra aplicación. En este caso, usaremos una imagen de Python.
FROM python:3.10-slim
FROM python:3.11-slim as builder

# Establecemos el directorio de trabajo dentro del contenedor
WORKDIR /app

# Copiamos el archivo de requerimientos de Python
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

COPY requirements.txt .

# Instalamos las dependencias de la aplicación
RUN pip install --no-cache-dir -r requirements.txt
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /app/wheels -r requirements.txt

FROM python:3.11-slim

WORKDIR /app

COPY --from=builder /app/wheels /wheels
COPY --from=builder /app/requirements.txt .

RUN pip install --no-cache /wheels/*

# Copiamos el código fuente de la aplicación al contenedor
COPY . .

# Aplicamos migraciones
RUN python manage.py migrate
RUN ["python", "manage.py", "migrate"]

# Exponemos el puerto en el que se ejecuta la aplicación
EXPOSE 8000

# Comando para ejecutar la aplicación
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
CMD ["gunicorn", "--bind", ":8000", "--workers", "2", "vetsoft.wsgi"]

0 comments on commit 651b940

Please sign in to comment.