|
|
|
FROM node:18 as frontend-build |
|
WORKDIR /app |
|
COPY frontend/package*.json ./ |
|
|
|
RUN npm config set registry https://registry.npmmirror.com/ |
|
RUN npm install |
|
COPY frontend/ ./ |
|
|
|
|
|
ENV REACT_APP_NODE_ENV=production |
|
|
|
RUN npm run build |
|
|
|
|
|
FROM python:3.12-slim |
|
WORKDIR /app |
|
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \ |
|
curl ca-certificates git netcat-openbsd && \ |
|
curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \ |
|
apt-get install -y nodejs && \ |
|
rm -rf /var/lib/apt/lists/* |
|
|
|
|
|
RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \ |
|
mv /root/.local/bin/uv /usr/local/bin/uv && chmod +x /usr/local/bin/uv |
|
|
|
|
|
RUN uv --version |
|
|
|
|
|
RUN useradd -m -u 1000 user |
|
|
|
|
|
RUN mkdir -p /app/.cache && \ |
|
chown -R user:user /app |
|
|
|
|
|
COPY backend/ . |
|
|
|
|
|
RUN pip install fastapi uvicorn |
|
|
|
RUN uv pip install -e . --system |
|
|
|
|
|
COPY --from=frontend-build /app/build ./frontend/build |
|
COPY --from=frontend-build /app/package*.json ./frontend/ |
|
COPY --from=frontend-build /app/server.js ./frontend/ |
|
|
|
|
|
WORKDIR /app/frontend |
|
|
|
RUN npm config set registry https://registry.npmmirror.com/ |
|
RUN npm install --production |
|
WORKDIR /app |
|
|
|
|
|
ENV HF_HOME=/app/.cache \ |
|
HF_DATASETS_CACHE=/app/.cache \ |
|
INTERNAL_API_PORT=7861 \ |
|
PORT=7860 \ |
|
NODE_ENV=production |
|
|
|
|
|
USER user |
|
EXPOSE 7860 7861 |
|
|
|
|
|
CMD ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port 7861 & while ! nc -z 127.0.0.1 7861; do sleep 1; done && cd frontend && npm run serve"] |