LAST233 commited on
Commit
df3b6ab
·
verified ·
1 Parent(s): 0d23e3f

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +6 -32
Dockerfile CHANGED
@@ -18,35 +18,7 @@ RUN useradd -m -s /bin/bash coder && \
18
  # 安装基础依赖和code-server
19
  RUN apt-get update && apt-get install -y && \
20
  DEBIAN_FRONTEND=noninteractive apt-get install gcc g++ gdb clangd wget git curl jq tzdata -y && \
21
- curl -fsSL https://code-server.dev/install.sh | sh
22
-
23
- # 安装frpc
24
- # RUN cd /usr/local/bin && \
25
- # wget -O /usr/local/bin/frpc https://nya.globalslb.net/natfrp/client/frpc/0.51.0-sakura-12.3/frpc_linux_amd64 && \
26
- # chmod 755 /usr/local/bin/frpc && \
27
- # ls -l /usr/local/bin/frpc && \
28
- # md5sum /usr/local/bin/frpc
29
-
30
- # 配置frpc与codeserver同时运行
31
- RUN echo '#!/bin/bash\n\
32
- # ===== 从环境变量配置Git身份和凭证 =====\n\
33
- # if [ -n \"${GH_USERNAME}\" ] && [ -n \"${GH_EMAIL}\" ]; then\n\
34
- # git config --global user.name \"${GH_USERNAME}\"\n\
35
- # git config --global user.email \"${GH_EMAIL}\"\n\
36
- # echo \"Git用户身份已从环境变量设置。\"\n\
37
- # fi\n\
38
- # if [ -n \"${GH_TOKEN}\" ]; then\n\
39
- # # 将令牌安全地存储到Git凭证文件中[citation:1]\n\
40
- # echo \"https://${GH_USERNAME}:${GH_TOKEN}@github.com\" > ~/.git-credentials\n\
41
- # echo \"GitHub令牌凭证已设置。\"\n\
42
- # fi\n\
43
- # 1. 启动 frpc (后台运行)\n\
44
- # /usr/local/bin/frpc -f ${FRP_TOKEN} &\n\
45
- # 2. 前台启动 code-server (保持容器运行)\n\
46
- # git remote set-url origin https://${GH_TOKEN}@github.com/${GH_USERNAME}/${HUB_NAME}.git \n\
47
- # git clone https://github.com/${GH_USERNAME}/${HUB_NAME}.git \n\
48
- exec code-server /home/coder/cpp_competition' > /home/coder/start.sh
49
- RUN chmod +x /home/coder/start.sh
50
 
51
  COPY settings.json /home/coder/.local/share/code-server/User/
52
  COPY config.yaml /home/coder/.config/code-server/
@@ -74,12 +46,14 @@ RUN code-server --install-extension /home/coder/cph-ng-0.5.5.vsix && \
74
 
75
  RUN /home/coder/create_languagepacks.sh
76
 
77
- RUN git remote set-url origin https://${GH_TOKEN}@github.com/${GH_USERNAME}/${HUB_NAME}.git && \
78
- git clone https://github.com/${GH_USERNAME}/${HUB_NAME}.git
 
 
79
 
80
  # 暴露端口
81
  EXPOSE 8080
82
  EXPOSE 7860
83
 
84
  # 将启动脚本设为容器入口
85
- CMD ["/home/coder/start.sh"]
 
18
  # 安装基础依赖和code-server
19
  RUN apt-get update && apt-get install -y && \
20
  DEBIAN_FRONTEND=noninteractive apt-get install gcc g++ gdb clangd wget git curl jq tzdata -y && \
21
+ curl -fsSL https://code-server.dev/install.sh | sh
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
  COPY settings.json /home/coder/.local/share/code-server/User/
24
  COPY config.yaml /home/coder/.config/code-server/
 
46
 
47
  RUN /home/coder/create_languagepacks.sh
48
 
49
+ RUN --mount=type=secret,id=SECRET_EXAMPLE,mode=0444,required=true \
50
+ git init && \
51
+ git remote set-url origin https://$(cat /run/secrets/GH_TOKEN)@github.com/$(cat /run/secrets/GH_USERNAME)/$(cat /run/secrets/HUB_NAME).git && \
52
+ git clone https://github.com/$(cat /run/secrets/GH_USERNAME)/$(cat /run/secrets/HUB_NAME).git
53
 
54
  # 暴露端口
55
  EXPOSE 8080
56
  EXPOSE 7860
57
 
58
  # 将启动脚本设为容器入口
59
+ CMD ["code-server", "/home/coder/cpp_competition"]