File size: 1,836 Bytes
c373af3
0acdbb9
efb6def
ba52a3d
fc15d7a
f76ba25
c20a15c
fc15d7a
1d9a43a
f808303
ba52a3d
590acbc
2ff41da
c20a15c
 
7f15058
fc15d7a
2ff41da
 
69085a4
2ff41da
ff63908
f808303
69085a4
 
 
ba52a3d
69085a4
 
 
f808303
240233c
63ce04b
0acdbb9
3ce4482
b9495b5
773951f
 
 
c20a15c
 
723e756
b4efd6f
74c7bbc
ba52a3d
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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