beraw / Dockerfile
raw9's picture
Update Dockerfile
e9ada35 verified
# Base Image (LTS version for maximum stability)
FROM ubuntu:22.04
# Environment Variables
ENV DEBIAN_FRONTEND=noninteractive
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
# Install Core Professional Tools + Network Diagnostic Tools (net-tools, iproute2, lsof)
RUN apt-get update && apt-get install -y --no-install-recommends \
curl wget git htop nano vim python3 python3-pip sudo zsh tmux unzip locales \
net-tools iproute2 lsof procps \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# Web Terminal (ttyd) Setup - Silent and secure download
RUN wget -q https://github.com/tsl0922/ttyd/releases/download/1.7.3/ttyd.x86_64 -O /usr/local/bin/ttyd \
&& chmod +x /usr/local/bin/ttyd
# Create User and Setup Sudo safely
RUN useradd -m -s /bin/zsh -u 1000 user \
&& echo "user ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
USER user
ENV HOME=/home/user
ENV PATH="/home/user/.local/bin:${PATH}"
WORKDIR $HOME/app
# ULTRA-FAST ZSH SETUP (No Oh-My-Zsh, zero lag, instant response)
RUN echo "autoload -U colors && colors" > ~/.zshrc \
&& echo "PROMPT=$'\n%{$fg[cyan]%}%~%{$reset_color%}\n%{$fg[green]%}❯%{$reset_color%} '" >> ~/.zshrc \
&& echo "alias ll='ls -alF'" >> ~/.zshrc \
&& echo "alias la='ls -A'" >> ~/.zshrc \
&& echo "alias l='ls -CF'" >> ~/.zshrc \
&& echo "clear" >> ~/.zshrc
# ZERO-LATENCY TMUX CONFIG (Mouse OFF for native text selection)
RUN echo 'set -g default-terminal "screen-256color"' > ~/.tmux.conf \
&& echo 'set -g mouse off' >> ~/.tmux.conf \
&& echo 'set -s escape-time 0' >> ~/.tmux.conf \
&& echo 'set -g history-limit 100000' >> ~/.tmux.conf \
&& echo 'set -g status-bg "#000000"' >> ~/.tmux.conf \
&& echo 'set -g status-fg "#ffffff"' >> ~/.tmux.conf \
&& echo 'set -g status-left-length 50' >> ~/.tmux.conf \
&& echo 'set -g status-left "#[fg=#ffffff,bg=#222222,bold] WORKSPACE [#S] #[bg=#000000] "' >> ~/.tmux.conf \
&& echo 'set -g status-right "#[fg=#888888]%Y-%m-%d #[fg=#ffffff]%H:%M "' >> ~/.tmux.conf \
&& echo 'set -g pane-border-style fg="#333333"' >> ~/.tmux.conf \
&& echo 'set -g pane-active-border-style fg="#555555",bg=default' >> ~/.tmux.conf
# 🚀 OPTIMIZATION: Copy requirements first to leverage Docker Layer Caching
COPY --chown=user:user requirements.txt $HOME/app/
# Safely install Python Requirements
RUN if grep -q '^[^#[:space:]]' requirements.txt; then \
pip3 install --no-cache-dir --upgrade pip && \
pip3 install --no-cache-dir -r requirements.txt; \
else \
echo "No active python packages found to install."; \
fi
# Copy the rest of the project files
COPY --chown=user:user . $HOME/app
# Port for ttyd or FastAPI
EXPOSE 7860
# Default execution command
CMD ["python3", "app.py"]