72 lines
2.0 KiB
Docker
72 lines
2.0 KiB
Docker
# =========================
|
|
# Etapa de Build
|
|
# =========================
|
|
FROM python:3.12-slim AS build
|
|
|
|
# Instalar dependencias de build mínimas
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
build-essential \
|
|
python3-venv \
|
|
pip \
|
|
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
|
|
|
# Crear un entorno virtual Python para build
|
|
RUN python -m venv /opt/venv
|
|
ENV PATH="/opt/venv/bin:$PATH"
|
|
|
|
# Actualizar pip y herramientas de build
|
|
RUN pip install --upgrade pip setuptools wheel build pipenv
|
|
|
|
# Copiar código y preparar build
|
|
ADD src /app
|
|
WORKDIR /app
|
|
|
|
# Instalar dependencias y construir la rueda
|
|
RUN pipenv install --deploy --system || true
|
|
RUN python -m build -w
|
|
|
|
# =========================
|
|
# Etapa de Runtime
|
|
# =========================
|
|
FROM python:3.12-slim
|
|
|
|
ARG BUILD_DATE
|
|
LABEL org.label-schema.maintainer="Diego Fernández Carvajal (diego.fdezcarvajal@emtmadrid.es)" \
|
|
org.label-schema.build-dockerfile="11/12/2025" \
|
|
org.label-schema.build=$BUILD_DATE
|
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
ENV TZ=Europe/Madrid
|
|
ENV PYTHONUNBUFFERED=1
|
|
ENV PATH="/opt/venv/bin:$PATH"
|
|
|
|
WORKDIR /app
|
|
|
|
# Instalar dependencias mínimas de runtime
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
python3-venv \
|
|
supervisor \
|
|
tzdata \
|
|
locales \
|
|
&& ln -fs /usr/share/zoneinfo/$TZ /etc/localtime \
|
|
&& echo $TZ > /etc/timezone \
|
|
&& echo "es_ES.UTF-8 UTF-8" > /etc/locale.gen \
|
|
&& echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \
|
|
&& locale-gen \
|
|
&& apt-get clean && apt-get autoremove -y \
|
|
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
|
|
|
# Copiar supervisord
|
|
COPY /man/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
|
|
|
# Copiar ruedas desde build
|
|
COPY --from=build /app/dist/*.whl /app/
|
|
|
|
# Crear entorno virtual para runtime
|
|
RUN python -m venv /opt/venv
|
|
|
|
# Instalar ruedas en el entorno virtual
|
|
RUN pip install --upgrade pip setuptools wheel
|
|
RUN pip install /app/*.whl -t /app
|
|
|
|
CMD ["/usr/bin/supervisord","-c","/etc/supervisor/conf.d/supervisord.conf"] |