Spaces:
Building
Building
# Get a distribution that has uv already installed | |
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim | |
# Install supervisor and nginx | |
RUN apt-get update && apt-get install -y supervisor nginx && rm -rf /var/lib/apt/lists/* | |
# Add user - this is the user that will run the app | |
# If you do not set user, the app will run as root (undesirable) | |
RUN useradd -m -u 1000 user | |
USER user | |
# Set the home directory and path | |
ENV HOME=/home/user \ | |
PATH=/home/user/.local/bin:$PATH | |
ENV UVICORN_WS_PROTOCOL=websockets | |
# Set the working directory | |
WORKDIR $HOME/app | |
# Copy the app to the container | |
COPY --chown=user . $HOME/app | |
# Install the dependencies | |
# RUN uv sync --frozen | |
RUN uv sync | |
# Switch to root to setup supervisor and nginx | |
USER root | |
# Configure nginx | |
# COPY nginx.conf /etc/nginx/nginx.conf | |
# Create supervisor configuration and directories | |
RUN mkdir -p /var/log/supervisor && \ | |
mkdir -p /home/user/supervisor && \ | |
chown -R user:user /home/user/supervisor | |
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf | |
# Create required nginx directories and set permissions | |
# RUN mkdir -p /var/log/nginx /var/lib/nginx /var/cache/nginx && \ | |
# chown -R user:user /var/log/nginx /var/lib/nginx /var/cache/nginx | |
# Switch back to user for running the services | |
USER user | |
# Expose only the nginx port | |
EXPOSE 7860 | |
# Run supervisor (doesn't work) | |
# CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] | |
# Run only FastAPI | |
CMD ["uv", "run", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |
# Run only Chainlit | |
# CMD ["uv", "run", "chainlit", "run", "app.py", "--host", "0.0.0.0", "--port", "7860"] |