Primera prueba de código de microservicios
Some checks failed
build / build (push) Failing after 0s
test / echo (push) Has been cancelled

This commit is contained in:
2025-12-12 12:59:20 +01:00
commit 85d023acec
7 changed files with 251 additions and 0 deletions

72
Dockerfile Normal file
View File

@@ -0,0 +1,72 @@
# =========================
# 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"]