Spaces:
Sleeping
Sleeping
File size: 1,801 Bytes
102c540 d3dec26 102c540 d3dec26 102c540 d3dec26 102c540 d3dec26 102c540 d3dec26 2b61f9d d3dec26 2b61f9d d3dec26 eb54d76 d3dec26 2b61f9d d3dec26 7a1c9d6 29e8e4d d3dec26 2b61f9d 102c540 d3dec26 eb54d76 d3dec26 2b61f9d 97eff50 2b61f9d eb54d76 d3dec26 | 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 53 54 55 56 57 58 59 60 61 | FROM node:18 AS frontend-builder
WORKDIR /app/frontend
# Copy frontend package files and install dependencies in one layer
COPY app/frontend/package*.json ./
RUN npm install && \
npm uninstall tailwindcss @tailwindcss/postcss && \
npm install tailwindcss@3.3.0 postcss autoprefixer --save-dev
# Copy frontend source files and build in one layer
COPY app/frontend/ ./
RUN npm run build && ls -la build/
# Backend stage
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim
ENV UVICORN_WS_PROTOCOL=websockets
# Create a non-root user in one layer
RUN groupadd -r appuser && useradd -r -g appuser -m -u 1000 -d /home/appuser -s /sbin/nologin appuser
USER appuser
WORKDIR /app
COPY uv.lock pyproject.toml /app/
RUN uv sync
# Copy application files in one layer
COPY aimakerspace/ /app/aimakerspace/
COPY api/ /app/api/
# Set up directories and copy frontend build files
RUN mkdir -p /app/logs /app/static/css /app/static/js && \
chmod -R 777 /app/logs
COPY --from=frontend-builder /app/frontend/build/static/css/* /app/static/css/
COPY --from=frontend-builder /app/frontend/build/static/js/* /app/static/js/
COPY --from=frontend-builder /app/frontend/build/index.html /app/static/
COPY --from=frontend-builder /app/frontend/build/asset-manifest.json /app/static/
# Set ownership in one layer
RUN chown -R appuser:appuser /app/logs
# Set environment variables in one layer
ENV PYTHONPATH=/app \
PORT=7860 \
HOST=0.0.0.0 \
LANGCHAIN_TRACING_V2=true \
LANGSMITH_TRACING=true \
LANGSMITH_PROJECT=pythonic-rag \
LANGSMITH_ENDPOINT=https://api.smith.langchain.com
# Expose the Hugging Face required port
EXPOSE 7860
# Switch to non-root user
USER appuser
# Start the application
CMD ["uv", "run", "uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "7860"] |