42 lines
1.7 KiB
Docker
42 lines
1.7 KiB
Docker
# Python 3.12 — webapp + server-side rescan (help_processor)
|
||
FROM python:3.12-slim
|
||
|
||
WORKDIR /app
|
||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||
libxml2 \
|
||
&& rm -rf /var/lib/apt/lists/*
|
||
|
||
COPY requirements-webapp.txt /app/
|
||
RUN pip install --no-cache-dir -r requirements-webapp.txt
|
||
|
||
COPY VERSION /app/VERSION
|
||
COPY webapp /app/webapp
|
||
COPY help_processor.py /app/help_processor.py
|
||
COPY help_codes.py /app/help_codes.py
|
||
COPY Bairaci.png /app/Bairaci.png
|
||
|
||
# Git SHA after COPY so pip layer stays cached.
|
||
# Coolify: Advanced → Include Source Commit in Build = ON
|
||
# (или Build ARG GIT_SHA). Иначе се ползва hash на копираните файлове.
|
||
ARG SOURCE_COMMIT=
|
||
ARG GIT_SHA=
|
||
RUN GIT_SHA="$GIT_SHA" SOURCE_COMMIT="$SOURCE_COMMIT" python -c 'import hashlib,os,pathlib,sys; sha=(os.environ.get("GIT_SHA") or os.environ.get("SOURCE_COMMIT") or "").strip(); h=hashlib.sha1(); \
|
||
[h.update(p.as_posix().encode()+p.read_bytes()) for p in sorted(pathlib.Path("/app").rglob("*")) if p.is_file() and "/__pycache__/" not in p.as_posix() and p.name!="BUILD_ID"]; \
|
||
pathlib.Path("/app/BUILD_ID").write_text(sha or h.hexdigest()[:12], encoding="utf-8"); \
|
||
print("BUILD_ID", pathlib.Path("/app/BUILD_ID").read_text(), file=sys.stderr)'
|
||
ENV APP_GIT_SHA=${GIT_SHA}
|
||
|
||
ENV OUTPUT_DIR=/mnt/mssql/share/RIP/RIP_Help_Source/Output
|
||
ENV HOME_IMAGE=/app/Bairaci.png
|
||
ENV HELP_REMOTE_ROOT=/mnt/mssql/share/RIP/RIP_Help_Source/Output
|
||
# Set in Coolify (required for /api/rescan):
|
||
# ANTHROPIC_API_KEY=...
|
||
# HELP_DB_CONN=...
|
||
# Optional:
|
||
# RESCAN_TOKEN=secret → require header X-Rescan-Token
|
||
|
||
EXPOSE 8000
|
||
|
||
CMD ["uvicorn", "webapp.main:app", "--host", "0.0.0.0", "--port", "8000", "--proxy-headers", "--forwarded-allow-ips=*"]
|