|
|
|
FROM node:20-alpine AS builder |
|
RUN apk add --no-cache libc6-compat |
|
WORKDIR /app |
|
|
|
|
|
RUN mkdir -p /tmp/huggingface && \ |
|
chmod -R 777 /tmp/huggingface && \ |
|
mkdir -p /app/workspace && \ |
|
chmod -R 777 /app/workspace |
|
|
|
|
|
ENV HF_HOME=/tmp/huggingface \ |
|
TRANSFORMERS_CACHE=/tmp/huggingface \ |
|
XDG_CACHE_HOME=/tmp \ |
|
WRITABLE_DIR=/app/workspace |
|
|
|
|
|
COPY frontend ./frontend |
|
WORKDIR /app/frontend |
|
RUN if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ |
|
elif [ -f package-lock.json ]; then npm ci; \ |
|
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \ |
|
else echo "No lockfile found. Exiting." && exit 1; \ |
|
fi |
|
RUN npm run build |
|
|
|
|
|
FROM python:3.12-slim AS backend |
|
WORKDIR /app |
|
|
|
|
|
RUN apt-get update --fix-missing && \ |
|
apt-get install --no-install-recommends -y git curl locales && \ |
|
sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \ |
|
locale-gen en_US.UTF-8 && \ |
|
apt-get clean && rm -rf /var/lib/apt/lists/* |
|
|
|
|
|
ENV LANG=en_US.UTF-8 \ |
|
LANGUAGE=en_US:en \ |
|
LC_ALL=en_US.UTF-8 \ |
|
PYTHONIOENCODING=utf-8 |
|
|
|
|
|
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \ |
|
apt-get update --fix-missing && \ |
|
apt-get install --no-install-recommends -y nodejs && \ |
|
apt-get clean && rm -rf /var/lib/apt/lists/* |
|
|
|
|
|
COPY requirements.txt . |
|
RUN pip install --no-cache-dir -r requirements.txt |
|
RUN pip install --no-cache-dir torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cu124 |
|
RUN python -m spacy download en_core_web_sm |
|
|
|
|
|
ENV DEEPEVAL_TELEMETRY_OPT_OUT=YES |
|
|
|
|
|
COPY . . |
|
COPY --from=builder /app/frontend/build ./frontend/build |
|
|
|
|
|
RUN mkdir -p /tmp/huggingface /app/workspace && \ |
|
chmod -R 777 /tmp/huggingface /app/workspace && \ |
|
useradd -m spaces-user && \ |
|
chown -R spaces-user:spaces-user /tmp/huggingface /app/workspace |
|
|
|
USER spaces-user |
|
|
|
EXPOSE ${PORT:-7860} |
|
|
|
CMD ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port ${PORT:-7860}"] |