Files
plantillas-proyectos/backend/Dockerfile
AlexeerCT 4bc38b691f Add APP_VERSION handling in Dockerfile and config.py
Updated the Dockerfile to include an ARG and ENV for APP_VERSION, allowing for version specification during build time. Modified config.py to set a default APP_VERSION, which can be overridden by the environment, enhancing flexibility for deployment and runtime configuration.
2026-04-02 11:31:00 -05:00

57 lines
1.5 KiB
Docker

FROM python:3.11-slim
WORKDIR /app
# Instalar dependencias del sistema
RUN apt-get update && apt-get install -y \
gcc \
postgresql-client \
curl \
&& rm -rf /var/lib/apt/lists/*
# Instalar dependencias para wkhtmltopdf y reportes PDF
RUN apt-get update \
&& apt-get install -y \
xvfb \
fontconfig \
fonts-dejavu-core \
libfontconfig1 \
libxrender1 \
libxtst6 \
libxi6 \
libxrandr2 \
ca-certificates \
libjpeg62-turbo \
libpng16-16 \
&& rm -rf /var/lib/apt/lists/*
# Instalar wkhtmltopdf binario oficial con soporte para footers/headers
# TARGETARCH permite amd64 y arm64 (Apple Silicon)
ARG TARGETARCH
RUN curl -k -L -o /tmp/wkhtmltox.deb "https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-3/wkhtmltox_0.12.6.1-3.bookworm_${TARGETARCH}.deb" \
&& apt-get update \
&& apt-get install -y /tmp/wkhtmltox.deb \
&& rm /tmp/wkhtmltox.deb \
&& rm -rf /var/lib/apt/lists/* \
&& wkhtmltopdf --version
# Copiar requirements
COPY requirements.txt .
# Instalar dependencias Python
RUN pip install --no-cache-dir -r requirements.txt
# Copiar código
COPY . .
# Jenkins / CI pasan --build-arg APP_VERSION=…; debe quedar en ENV para runtime (API /version, OpenAPI, etc.)
ARG APP_VERSION=dev-local
ENV APP_VERSION=${APP_VERSION}
# Exponer puerto
EXPOSE 8000
# Comando por defecto
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]