litellm / Dockerfile
Astronut's picture
j
ae7b5c8
Raw History Blame Contribute Delete
3.03 kB
# Use Ubuntu as base for better Tailscale support
FROM ubuntu:22.04
# Avoid prompts from apt
ENV DEBIAN_FRONTEND=noninteractive
USER root
# Install dependencies including SSH server and Python3
RUN apt-get update && apt-get install -y \
curl \
ca-certificates \
openssh-server \
sudo \
gnupg \
lsb-release \
nginx \
python3 \
python3-pip
COPY tailscale-install.sh /tailscale-install.sh
RUN chmod +x /tailscale-install.sh
RUN /tailscale-install.sh && rm /tailscale-install.sh
RUN apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Set up a new user named "user" with user ID 1000
RUN useradd -m -u 1000 user && \
echo "user:password" | chpasswd && \
usermod -aG sudo user
# Prepare nginx directories
RUN mkdir -p /var/cache/nginx \
/var/log/nginx \
/var/lib/nginx
RUN touch /var/run/nginx.pid
RUN chown -R user:user /var/cache/nginx \
/var/log/nginx \
/var/lib/nginx \
/var/run/nginx.pid
# Create startup script
COPY start.sh /start.sh
RUN chown user:user /start.sh
RUN chmod +x /start.sh
# Copy pre-downloaded Tailscale install script
COPY tailscale-install.sh /tmp/tailscale-install.sh
# Install Tailscale from the local script
RUN chmod +x /tmp/tailscale-install.sh && /tmp/tailscale-install.sh && rm /tmp/tailscale-install.sh
# Configure SSH
RUN mkdir -p /var/run/sshd && \
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \
sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config && \
sed -i 's/#PubkeyAuthentication yes/PubkeyAuthentication yes/' /etc/ssh/sshd_config
# Prepare Tailscale directories
RUN mkdir -p /var/lib/tailscale /var/run/tailscale && \
chown -R root:root /var/lib/tailscale /var/run/tailscale
# Create .ssh directory for the user
RUN mkdir -p /home/user/.ssh && \
chmod 700 /home/user/.ssh && \
chown -R user:user /home/user/
# Copy nginx configuration
COPY nginx.conf /etc/nginx/sites-available/default
RUN chown -R user:user /etc/nginx
# Copy fallback page for when backend is unavailable
COPY fallback.html /home/user/fallback.html
RUN chown user:user /home/user/fallback.html
# Copy Python process manager
COPY app.py /home/user/app/app.py
RUN chown user:user /home/user/app/app.py && chmod +x /home/user/app/app.py
# Create directories needed by SSH
RUN mkdir -p /home/user/run /home/user/.ssh/hostkeys && \
chown -R user:user /home/user/run /home/user/.ssh
# Note: We stay as root user because sshd and tailscaled require root privileges
# Supervisord will handle user switching for individual programs as needed
# Set home to the user's home directory
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# Set the working directory to the user's home directory
WORKDIR $HOME/app
# Copy the current directory contents into the container
COPY --chown=user . $HOME/app
COPY --chown=user . .
EXPOSE 7860
CMD ["bash", "start.sh"]