Spaces:
Paused

ddda / Dockerfile
2
添加同步
11c931f
Raw History Blame Contribute Delete
1.98 kB
FROM ubuntu:22.04
# 安装基础依赖
RUN apt update && apt install -y curl nginx sudo
# 1. 安装基础依赖和开发工具 (合并步骤减少层数)
RUN apt-get update && apt-get install -y \
curl \
nginx \
sudo \
git \
build-essential \
python3 \
python3-pip \
git-lfs \
jq \
unzip \
zip \
vim \
nano \
wget \
htop \
tmux \
screen \
rsync \
&& rm -rf /var/lib/apt/lists/*
# 2. 安装 rclone (WebDAV客户端)
RUN curl https://rclone.org/install.sh | bash
# 1. 创建应用用户并设置权限
RUN useradd -m -u 1000 appuser && \
mkdir -p /var/www/html /var/log/nginx /var/lib/nginx/tmp && \
chown -R appuser:appuser /var/www /var/log/nginx /var/lib/nginx
# 2. 部署 Hello World 前端
RUN echo "<html><body>Hello World</body></html>" > /var/www/html/index.html
# 3. 安装 VS Code Server (code-server)
RUN curl -fsSL https://code-server.dev/install.sh | sh
# 4. 安装 Cloudflare Tunnel (官方方法)
RUN mkdir -p --mode=0755 /usr/share/keyrings && \
curl -fsSL https://pkg.cloudflare.com/cloudflare-main.gpg | tee /usr/share/keyrings/cloudflare-main.gpg >/dev/null && \
echo 'deb [signed-by=/usr/share/keyrings/cloudflare-main.gpg] https://pkg.cloudflare.com/cloudflared any main' | tee /etc/apt/sources.list.d/cloudflared.list && \
apt-get update && apt-get install -y cloudflared
# 5. 为应用用户设置权限
RUN mkdir -p /home/appuser/.config/code-server && \
mkdir -p /home/appuser/.local/share/code-server && \
chown -R appuser:appuser /home/appuser
# 6. 复制脚本文件并设置权限
COPY start.sh /start.sh
COPY webdav-sync.sh /webdav-sync.sh
COPY test-webdav.sh /test-webdav.sh
COPY rclone.conf.template /rclone.conf.template
RUN chmod +x /start.sh /webdav-sync.sh /test-webdav.sh
# 7. 设置工作目录和用户
WORKDIR /home/appuser
USER appuser
# 8. 设置 HOME 环境变量(关键!)
ENV HOME=/home/appuser
CMD ["/start.sh"]