FROM ubuntu:20.04 RUN useradd -m -s /bin/bash -u 1000 leo && \ echo "leo:zxcvbnm" | chpasswd && \ apt update && \ apt install -y curl bash-completion wget vim net-tools lsof nginx htop && \ # usermod -aG sudo leo && \ # echo "leo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \ chown -R leo:leo /bin /sbin/ /media /mnt /opt /usr /var /tmp /run /home RUN curl -fsSL https://raw.githubusercontent.com/cdr/code-server/main/install.sh | sh # 引入设置中创建的secret变量 RUN --mount=type=secret,id=password,mode=0444,required=true cat /run/secrets/password > /run/passwd # RUN ls /.config/ && cat /.config/code-server/config.yaml COPY ./config.yaml /home/leo/.config/code-server/config.yaml # RUN sed -i 's/psaaword/`cat /run/passwd`/' /home/leo/.config/code-server/config.yaml RUN echo "password: $(cat /run/passwd)" >> /home/leo/.config/code-server/config.yaml USER leo ENV HOME=/home/leo \ PATH=/home/leo/.local/bin:$PATH WORKDIR $HOME # WORKDIR /workspace EXPOSE 8080 # RUN sudo curl -fsSL https://raw.githubusercontent.com/cdr/code-server/main/install.sh | sh # 设置code-server启动脚本 #RUN echo "#!/bin/bash \n\ # code-server --bind-addr 0.0.0.0:8080 --auth none" > /root/startup.sh # RUN chmod +x /root/startup.sh # RUN mkdir /.config && chmod -R 777 /.config && mkdir /.local && chmod -R 777 /.local CMD ["code-server", "--bind-addr", "0.0.0.0:8080", "--config", "/home/leo/.config/code-server/config.yaml"] # CMD code-server --help # code-server项目仓库:https://github.com/cdr/code-server # hugging face docker 权限问题和环境变量的引用需了解:https://huggingface.co/docs/hub/spaces-sdks-docker # codeserver安装使用示例:https://betheme.net/houduan/3278.html?action=onClick