Spaces:
Running
Running
File size: 1,521 Bytes
df97e68 | 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 | # Gov Workflow OpenEnv
# Multi-stage image:
# 1) build Vite frontend assets
# 2) run FastAPI backend and serve built UI under /ui
FROM node:20-slim AS frontend-build
WORKDIR /web
COPY frontend/react/package.json frontend/react/package-lock.json ./frontend/react/
RUN cd frontend/react && npm ci --no-audit --no-fund
COPY frontend/react ./frontend/react
RUN cd frontend/react && npm run build
FROM python:3.11-slim AS runtime
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
OPENENV_DATA_DIR=/data/openenv_rl \
STORAGE_ENABLED=true \
PORT=7860
WORKDIR /app
# Runtime OS dependencies (torch/sb3 commonly require libgomp at runtime)
RUN apt-get update \
&& apt-get install -y --no-install-recommends libgomp1 \
&& rm -rf /var/lib/apt/lists/*
COPY requirements.txt requirements_rl.txt ./
RUN python -m pip install --upgrade pip \
&& python -m pip install -r requirements.txt \
&& python -m pip install -r requirements_rl.txt
COPY . .
COPY --from=frontend-build /web/frontend/react/dist ./app/web/vite_dist
RUN mkdir -p /data/openenv_rl \
&& useradd --create-home --uid 10001 appuser \
&& chown -R appuser:appuser /app /data/openenv_rl
USER appuser
EXPOSE 7860
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:7860/health', timeout=3)" || exit 1
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]
|