Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
53 lines (35 loc) · 1.68 KB
/
Copy pathDockerfile
File metadata and controls
53 lines (35 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
FROM python:3.13-slim-bookworm AS build
RUN apt-get update && apt-get upgrade -y --no-install-recommends \
&& apt-get install -y --no-install-recommends g++ make \
&& rm -rf /var/lib/apt/lists/*
COPY --from=ghcr.io/astral-sh/uv:0.12.12 /uv /bin/uv
ENV UV_COMPILE_BYTECODE=1 \
UV_LINK_MODE=copy \
UV_PYTHON_DOWNLOADS=never
WORKDIR /app
COPY pyproject.toml uv.lock .python-version ./
RUN uv sync --frozen --no-dev --no-install-project
COPY src/native ./src/native
# El puente Cython se compila con el Python del entorno (trae numpy y Cython); el del sistema no los tiene.
RUN make -C src/native PYTHON=/app/.venv/bin/python
COPY app ./app
FROM python:3.13-slim-bookworm
RUN apt-get update && apt-get upgrade -y --no-install-recommends && rm -rf /var/lib/apt/lists/*
LABEL org.opencontainers.image.title="SmartPot AI" \
org.opencontainers.image.description="Sistema experto, lógica difusa, modelos de ML y agente reactivo de SmartPot" \
org.opencontainers.image.source="https://github.com/SmartPotTech/SmartPot-AI" \
org.opencontainers.image.licenses="MIT"
ENV PATH="/app/.venv/bin:$PATH" \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PORT=8000 \
DATA_DIR=/data
WORKDIR /app
COPY --from=build /app /app
# Lecturas y modelos aprendidos: aquí se monta un volumen.
RUN mkdir -p /data && chown 1000:1000 /data
USER 1000:1000
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
CMD python -c "import os, urllib.request; urllib.request.urlopen(f'http://127.0.0.1:{os.environ[\"PORT\"]}/health', timeout=4)"
CMD ["sh", "-c", "exec uvicorn app.main:app --host 0.0.0.0 --port ${PORT} --no-server-header --proxy-headers"]