Baida commited on
Commit
ee677bf
Β·
verified Β·
1 Parent(s): 4039bbb

fix(docker): replace root multi-stage Dockerfile with backend-only Python Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +27 -38
Dockerfile CHANGED
@@ -1,49 +1,38 @@
1
- FROM node:22-bookworm AS frontend
2
- WORKDIR /app
3
-
4
- # Install pnpm via corepack
5
- RUN corepack enable && corepack prepare pnpm@10 --activate
6
-
7
- # Copy workspace config + lockfile first (cache layer for installs)
8
- COPY pnpm-workspace.yaml pnpm-lock.yaml package.json tsconfig.base.json ./
9
- COPY scripts/ ./scripts/
10
- COPY artifacts/agente-ai/package.json ./artifacts/agente-ai/
11
 
12
- # Install from workspace root β€” resolves all catalog: entries correctly
13
- RUN pnpm install --no-frozen-lockfile
 
 
 
14
 
15
- # Copy frontend source
16
- COPY artifacts/agente-ai/ ./artifacts/agente-ai/
17
-
18
- # Build frontend (2 GB heap for large bundles)
19
- RUN cd artifacts/agente-ai && NODE_OPTIONS=--max-old-space-size=2048 pnpm run build
20
-
21
- # ── Runtime ──────────────────────────────────────────────────────────────────
22
- FROM python:3.11-slim AS runtime
23
- ENV PYTHONDONTWRITEBYTECODE=1 \
24
- PYTHONUNBUFFERED=1 \
25
- PYTHONPATH=/app/backend \
26
- FRONTEND_DIST=/app/backend/static
27
  WORKDIR /app
28
 
29
  RUN apt-get update && apt-get install -y --no-install-recommends \
30
- build-essential \
31
- curl \
32
- git \
33
- tmux \
34
- libssl-dev \
35
- libffi-dev \
36
  && rm -rf /var/lib/apt/lists/*
37
 
38
- COPY backend/requirements.txt /app/backend/requirements.txt
39
- RUN pip install --no-cache-dir --upgrade pip setuptools wheel \
40
- && pip install --no-cache-dir -r /app/backend/requirements.txt
 
 
 
 
 
 
 
 
41
 
42
- COPY backend /app/backend
43
- COPY --from=frontend /app/artifacts/agente-ai/dist /app/backend/static
 
44
 
45
- WORKDIR /app/backend
46
- RUN python -c "import sys; print('Python', sys.version); from fastapi import FastAPI; print('FastAPI OK')"
47
 
48
  EXPOSE 7860
49
- CMD ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port ${PORT:-7860} --log-level info"]
 
1
+ FROM python:3.11-slim
 
 
 
 
 
 
 
 
 
2
 
3
+ ENV PYTHONUNBUFFERED=1 \
4
+ PYTHONDONTWRITEBYTECODE=1 \
5
+ PORT=7860 \
6
+ FRONTEND_DIST=/home/user/app/static \
7
+ PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
8
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  WORKDIR /app
10
 
11
  RUN apt-get update && apt-get install -y --no-install-recommends \
12
+ build-essential curl git nodejs npm \
13
+ libnss3 libnspr4 libdbus-1-3 libatk1.0-0 libatk-bridge2.0-0 \
14
+ libcups2 libdrm2 libxkbcommon0 libxcomposite1 libxdamage1 \
15
+ libxfixes3 libxrandr2 libgbm1 libasound2 \
 
 
16
  && rm -rf /var/lib/apt/lists/*
17
 
18
+ COPY requirements.txt /app/requirements.txt
19
+ RUN pip install --no-cache-dir -r /app/requirements.txt \
20
+ && playwright install chromium \
21
+ && chmod -R 755 /ms-playwright
22
+
23
+ ARG TTYD_VERSION=1.7.7
24
+ RUN ARCH=$(uname -m) && \
25
+ TTYD_ARCH=$([ "$ARCH" = "aarch64" ] && echo "aarch64" || echo "x86_64") && \
26
+ curl -fsSL -o /usr/local/bin/ttyd \
27
+ "https://github.com/tsl0922/ttyd/releases/download/${TTYD_VERSION}/ttyd.${TTYD_ARCH}" && \
28
+ chmod +x /usr/local/bin/ttyd
29
 
30
+ RUN useradd -m -u 1000 user
31
+ USER user
32
+ ENV HOME=/home/user PATH=/home/user/.local/bin:$PATH
33
 
34
+ WORKDIR /home/user/app
35
+ COPY --chown=user . /home/user/app/
36
 
37
  EXPOSE 7860
38
+ CMD ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port ${PORT:-7860} --workers 1"]