Spaces:
Building
Building
# Use an official Python 3.11 image as the base | |
FROM python:3.11-slim | |
# Install system dependencies for Caddy | |
RUN apt-get update && apt-get install -y debian-keyring debian-archive-keyring apt-transport-https curl gnupg2 | |
# Add Caddy's GPG key and repository | |
RUN curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg \ | |
&& curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list | |
# Update and install Caddy | |
RUN apt-get update && apt-get install -y caddy | |
# Create Caddyfile for reverse proxy | |
RUN echo ":7860 {\n \ | |
reverse_proxy localhost:8080\n \ | |
}" > /etc/caddy/Caddyfile | |
RUN useradd -m -u 1000 user | |
USER user | |
ENV PATH="/home/user/.local/bin:$PATH" | |
ENV PATH="/home/user/.local/bin:$PATH" | |
# Set the working directory | |
WORKDIR /app | |
# Reset pip source to ensure it's using pypi.org and upgrade pip | |
RUN pip config set global.index-url https://pypi.org/simple \ | |
&& python -m pip install --upgrade pip | |
# Install open-webui | |
RUN pip install open-webui | |
# Expose port 7860 | |
EXPOSE 7860 | |
COPY --chown=user . /app | |
CMD ["sh", "-c", "open-webui serve & caddy run --config /etc/caddy/Caddyfile"] |