idea / Dockerfile
oulh's picture
Update Dockerfile
590acbc
raw
history blame contribute delete
No virus
1.84 kB
FROM ubuntu:20.04
RUN apt update && \
apt install -y sudo curl bash-completion wget vim net-tools lsof htop nginx
RUN useradd -m -s /bin/bash -u 1000 leo && \
echo "leo:zxcvbnm" | chpasswd && \
usermod -aG sudo leo && \
echo "leo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
# chown leo:leo /bin /sbin/ /media /mnt /opt /usr /var /tmp /run /home
# chown -R leo:leo /etc/nginx /run /var
chmod -R 777 /etc/nginx /var/lib/nginx /var/log/nginx /run
ENV HOME=/home/leo \
PATH=/home/leo/.local/bin:$PATH
WORKDIR $HOME
COPY ./config.yaml $HOME/.config/code-server/config.yaml
# 引入设置中创建的secret变量
RUN --mount=type=secret,id=password,mode=0444,required=true \
# (/run/secrets/password 只能在此次RUN中访问)
echo "password: $(cat /run/secrets/password)" >> $HOME/.config/code-server/config.yaml
USER leo
RUN curl -fsSL https://raw.githubusercontent.com/cdr/code-server/main/install.sh | sudo sh
# RUN sudo apt install nginx -y
EXPOSE 8080 80
# 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
# [1]hugging face docker 权限问题和环境变量的引用需了解:https://huggingface.co/docs/hub/spaces-sdks-docker
# [2]code-server项目仓库:https://github.com/cdr/code-server
# [3]codeserver安装使用示例:https://betheme.net/houduan/3278.html?action=onClick
# [4]nginx下非root账户的安装及配置 https://www.cnblogs.com/bq-med/articles/17110127.html