Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +16 -7
Dockerfile
CHANGED
|
@@ -25,8 +25,19 @@ RUN cd /usr/local/bin && \
|
|
| 25 |
|
| 26 |
# 配置frpc与codeserver同时运行
|
| 27 |
RUN echo '#!/bin/bash\n\
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
# 1. 启动 frpc (后台运行)\n\
|
| 29 |
-
/usr/local/bin/frpc -f
|
| 30 |
# 2. 前台启动 code-server (保持容器运行)\n\
|
| 31 |
exec code-server /home/coder/cpp_competition' > /start.sh
|
| 32 |
RUN chmod +x /start.sh
|
|
@@ -47,14 +58,12 @@ RUN code-server --install-extension /home/cph-ng-0.5.5.vsix && \
|
|
| 47 |
/home/create_languagepacks.sh
|
| 48 |
|
| 49 |
# 配置git
|
| 50 |
-
RUN git
|
| 51 |
-
git config --global user.email "lin2011746853@outlook.com" && \
|
| 52 |
-
git config --global credential.helper store && \
|
| 53 |
-
git config --global credential.https://Save-it@github.com.username Save-it && \
|
| 54 |
-
git config --global credential.https://Save-it@github.com.password ${GH_TOKEN} && \
|
| 55 |
-
git clone https://github.com/Save-it/cpp_competition.git /home/coder/cpp_competition && \
|
| 56 |
echo '*.exe \n *.out' > /home/coder/cpp_competition/.gitignore
|
| 57 |
|
|
|
|
|
|
|
|
|
|
| 58 |
# 暴露端口
|
| 59 |
EXPOSE 8080
|
| 60 |
EXPOSE 7860
|
|
|
|
| 25 |
|
| 26 |
# 配置frpc与codeserver同时运行
|
| 27 |
RUN echo '#!/bin/bash\n\
|
| 28 |
+
# ===== 从环境变量配置Git身份和凭证 =====\n\
|
| 29 |
+
if [ -n \"${GH_USERNAME}\" ] && [ -n \"${GH_EMAIL}\" ]; then\n\
|
| 30 |
+
git config --global user.name \"${GH_USERNAME}\"\n\
|
| 31 |
+
git config --global user.email \"${GH_EMAIL}\"\n\
|
| 32 |
+
echo \"Git用户身份已从环境变量设置。\"\n\
|
| 33 |
+
fi\n\
|
| 34 |
+
if [ -n \"${GH_TOKEN}\" ]; then\n\
|
| 35 |
+
# 将令牌安全地存储到Git凭证文件中[citation:1]\n\
|
| 36 |
+
echo \"https://${GH_USERNAME}:${GH_TOKEN}@github.com\" > ~/.git-credentials\n\
|
| 37 |
+
echo \"GitHub令牌凭证已设置。\"\n\
|
| 38 |
+
fi\n\
|
| 39 |
# 1. 启动 frpc (后台运行)\n\
|
| 40 |
+
/usr/local/bin/frpc -f ${FRP_TOKEN} &\n\
|
| 41 |
# 2. 前台启动 code-server (保持容器运行)\n\
|
| 42 |
exec code-server /home/coder/cpp_competition' > /start.sh
|
| 43 |
RUN chmod +x /start.sh
|
|
|
|
| 58 |
/home/create_languagepacks.sh
|
| 59 |
|
| 60 |
# 配置git
|
| 61 |
+
RUN git clone https://github.com/Save-it/cpp_competition.git /home/coder/cpp_competition && \
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
echo '*.exe \n *.out' > /home/coder/cpp_competition/.gitignore
|
| 63 |
|
| 64 |
+
# 将 /home/coder 下所有文件的所有权移交给 coder 用户
|
| 65 |
+
RUN chown -R coder:coder /home/coder
|
| 66 |
+
|
| 67 |
# 暴露端口
|
| 68 |
EXPOSE 8080
|
| 69 |
EXPOSE 7860
|