Spaces:
Sleeping
Sleeping
| FROM node:20-bookworm-slim AS frontend-builder | |
| WORKDIR /build/main | |
| ENV NEXT_TELEMETRY_DISABLED=1 | |
| ARG NEXT_PUBLIC_API_BASE_URL="" | |
| ARG NEXT_INTERNAL_API_PROXY_TARGET="http://127.0.0.1:8000" | |
| ARG NEXT_PUBLIC_GOOGLE_CLIENT_ID="" | |
| ENV NEXT_PUBLIC_API_BASE_URL=${NEXT_PUBLIC_API_BASE_URL} | |
| ENV NEXT_INTERNAL_API_PROXY_TARGET=${NEXT_INTERNAL_API_PROXY_TARGET} | |
| ENV NEXT_PUBLIC_GOOGLE_CLIENT_ID=${NEXT_PUBLIC_GOOGLE_CLIENT_ID} | |
| COPY main/package.json main/package-lock.json ./ | |
| RUN npm ci | |
| COPY main ./ | |
| RUN npm run build && npm prune --omit=dev | |
| FROM node:20-bookworm-slim | |
| WORKDIR /app | |
| ENV PYTHONDONTWRITEBYTECODE=1 | |
| ENV PYTHONUNBUFFERED=1 | |
| ENV NEXT_TELEMETRY_DISABLED=1 | |
| ENV NODE_ENV=production | |
| ENV PORT=7860 | |
| ENV PATH="/opt/venv/bin:${PATH}" | |
| ENV HF_HOME=/app/.cache/huggingface | |
| ENV HUGGINGFACE_HUB_CACHE=/app/.cache/huggingface/hub | |
| RUN apt-get update \ | |
| && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| ca-certificates \ | |
| curl \ | |
| ffmpeg \ | |
| git \ | |
| libcairo2 \ | |
| libffi-dev \ | |
| libgomp1 \ | |
| libsndfile1 \ | |
| nginx \ | |
| python3 \ | |
| python3-dev \ | |
| python3-pip \ | |
| python3-venv \ | |
| && rm -rf /var/lib/apt/lists/* | |
| RUN python3 -m venv /opt/venv | |
| COPY api/api-gateway/requirements.txt /tmp/api-gateway-requirements.txt | |
| COPY api/auth-service/requirements.txt /tmp/auth-service-requirements.txt | |
| COPY api/ai-service/requirements.txt /tmp/ai-service-requirements.txt | |
| RUN pip install --no-cache-dir --upgrade pip setuptools wheel \ | |
| && pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cpu torch torchaudio \ | |
| && pip install --no-cache-dir \ | |
| -r /tmp/api-gateway-requirements.txt \ | |
| -r /tmp/auth-service-requirements.txt \ | |
| -r /tmp/ai-service-requirements.txt \ | |
| && python -c "from pathlib import Path; import unidic, unidic_lite; target = Path(unidic_lite.__file__).parent / 'dicdir'; link = Path(unidic.__file__).parent / 'dicdir'; link.exists() or link.symlink_to(target, target_is_directory=True)" | |
| RUN python -c "from transformers import CLIPModel, CLIPProcessor; model='openai/clip-vit-base-patch32'; CLIPModel.from_pretrained(model); CLIPProcessor.from_pretrained(model)" | |
| COPY api /app/api | |
| COPY router /app/router | |
| COPY --from=frontend-builder /build/main /app/main | |
| COPY deploy/huggingface/nginx.conf /etc/nginx/nginx.conf | |
| COPY deploy/huggingface/start-hf.sh /app/start-hf.sh | |
| RUN chmod +x /app/start-hf.sh \ | |
| && mkdir -p \ | |
| /app/ai \ | |
| /app/.cache/huggingface \ | |
| /app/router/ai/public/generated_routes \ | |
| /tmp/nginx-client-body \ | |
| /tmp/nginx-proxy \ | |
| /tmp/nginx-fastcgi \ | |
| /tmp/nginx-uwsgi \ | |
| /tmp/nginx-scgi \ | |
| /tmp/runnimal-tts-cache | |
| EXPOSE 7860 | |
| CMD ["/app/start-hf.sh"] | |