Files
myrzx_bot/Dockerfile
T

46 lines
1.7 KiB
Docker

ARG NODE_IMAGE=node:22.23.3-bookworm-slim
FROM ${NODE_IMAGE} AS web-build
WORKDIR /build
COPY frontend/package*.json ./frontend/
RUN npm --prefix frontend ci --no-audit --no-fund
COPY frontend/ ./frontend/
COPY ranch_web/static/ ./ranch_web/static/
RUN npm --prefix frontend run build
FROM python:3.12-slim-bookworm
ARG WEB_VERSION=2.0.0.dev1
ARG VCS_REF=unknown
LABEL org.opencontainers.image.source="https://github.com/attilanet/myrzx_bot" \
org.opencontainers.image.title="myrzx_bot Web" \
org.opencontainers.image.version="${WEB_VERSION}" \
org.opencontainers.image.revision="${VCS_REF}"
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
WEB_CONCURRENCY=1 \
RANCH_WEB_HOST=0.0.0.0 \
RANCH_WEB_PORT=8765 \
RANCH_WEB_DATA_DIR=/data \
RANCH_WEB_UPDATER_DIR=/run/ranch-updater
WORKDIR /app
COPY ranch_web/requirements.txt /tmp/web-requirements.txt
RUN python -m pip install --no-cache-dir -r /tmp/web-requirements.txt \
&& groupadd --gid 10001 ranch \
&& useradd --uid 10001 --gid 10001 --no-create-home --shell /usr/sbin/nologin ranch \
&& mkdir -p /data /run/ranch-updater \
&& chown 10001:10001 /data
COPY ranch_assistant/ /app/ranch_assistant/
COPY ranch_web/ /app/ranch_web/
COPY --from=web-build /build/ranch_web/static/console/ /app/ranch_web/static/console/
COPY --from=web-build /build/ranch_web/static/index.html /app/ranch_web/static/index.html
USER 10001:10001
EXPOSE 8765
STOPSIGNAL SIGTERM
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
CMD ["python", "-c", "import urllib.request; r=urllib.request.urlopen('http://127.0.0.1:8765/api/health', timeout=3); assert r.status == 200"]
CMD ["python", "-m", "ranch_web", "--no-browser"]