Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +44 -30
Dockerfile
CHANGED
|
@@ -1,23 +1,24 @@
|
|
| 1 |
FROM ubuntu:22.04
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
# 安装基础依赖和code-server
|
| 4 |
-
RUN apt-get update && apt-get install -y \
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
&& curl -fsSL https://code-server.dev/install.sh | sh
|
| 8 |
-
RUN apt install gcc g++ gdb clangd wget git -y
|
| 9 |
-
RUN cd /usr/local/bin
|
| 10 |
-
RUN wget -O /usr/local/bin/frpc https://nya.globalslb.net/natfrp/client/frpc/0.51.0-sakura-12.3/frpc_linux_amd64
|
| 11 |
-
RUN chmod 755 /usr/local/bin/frpc
|
| 12 |
-
RUN ls -l /usr/local/bin/frpc
|
| 13 |
-
RUN md5sum /usr/local/bin/frpc
|
| 14 |
-
# 创建一个非root用户(可选,但更安全)
|
| 15 |
-
RUN useradd -m -s /bin/bash coder && \
|
| 16 |
-
echo "coder:coder" | chpasswd && \
|
| 17 |
-
usermod -aG sudo coder
|
| 18 |
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
|
|
|
| 21 |
RUN echo '#!/bin/bash\n\
|
| 22 |
# 1. 启动 frpc (后台运行)\n\
|
| 23 |
/usr/local/bin/frpc -f xi0ysolte634lz5zl7g2l80p5gvktkj5:24754182 &\n\
|
|
@@ -25,31 +26,44 @@ RUN echo '#!/bin/bash\n\
|
|
| 25 |
exec code-server /home/coder/cpp_competition' > /start.sh
|
| 26 |
RUN chmod +x /start.sh
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
# 设置工作目录和用户
|
| 29 |
WORKDIR /home/coder
|
|
|
|
| 30 |
# 切换回coder用户
|
| 31 |
USER coder
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
COPY cph-ng-0.5.5.vsix /home/
|
| 34 |
COPY vscode-luogu.vsix /home/
|
| 35 |
-
RUN code-server --install-extension /home/cph-ng-0.5.5.vsix
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
RUN
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
-
# 暴露
|
| 50 |
EXPOSE 8080
|
| 51 |
EXPOSE 7860
|
| 52 |
-
EXPOSE 27121
|
| 53 |
|
| 54 |
# 将启动脚本设为容器入口
|
| 55 |
CMD ["/start.sh"]
|
|
|
|
| 1 |
FROM ubuntu:22.04
|
| 2 |
|
| 3 |
+
# 系统变量
|
| 4 |
+
ENV GH_TOKEN = ${GH_TOKEN}
|
| 5 |
+
ENV LANG C.UTF-8
|
| 6 |
+
ENV LANGUAGE C.UTF-8
|
| 7 |
+
ENV TZ=Asia/Shanghai
|
| 8 |
+
|
| 9 |
# 安装基础依赖和code-server
|
| 10 |
+
RUN apt-get update && apt-get install -y && \
|
| 11 |
+
apt install gcc g++ gdb clangd wget git -y && \
|
| 12 |
+
url -fsSL https://code-server.dev/install.sh | sh
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
+
# 安装frpc
|
| 15 |
+
RUN cd /usr/local/bin && \
|
| 16 |
+
wget -O /usr/local/bin/frpc https://nya.globalslb.net/natfrp/client/frpc/0.51.0-sakura-12.3/frpc_linux_amd64 && \
|
| 17 |
+
chmod 755 /usr/local/bin/frpc && \
|
| 18 |
+
ls -l /usr/local/bin/frpc && \
|
| 19 |
+
md5sum /usr/local/bin/frpc
|
| 20 |
|
| 21 |
+
# 配置frpc与codeserver同时运行
|
| 22 |
RUN echo '#!/bin/bash\n\
|
| 23 |
# 1. 启动 frpc (后台运行)\n\
|
| 24 |
/usr/local/bin/frpc -f xi0ysolte634lz5zl7g2l80p5gvktkj5:24754182 &\n\
|
|
|
|
| 26 |
exec code-server /home/coder/cpp_competition' > /start.sh
|
| 27 |
RUN chmod +x /start.sh
|
| 28 |
|
| 29 |
+
|
| 30 |
+
# 创建一个非root用户(可选,但更安全)
|
| 31 |
+
RUN useradd -m -s /bin/bash coder && \
|
| 32 |
+
echo "coder:coder" | chpasswd && \
|
| 33 |
+
usermod -aG sudo coder
|
| 34 |
+
|
| 35 |
# 设置工作目录和用户
|
| 36 |
WORKDIR /home/coder
|
| 37 |
+
|
| 38 |
# 切换回coder用户
|
| 39 |
USER coder
|
| 40 |
|
| 41 |
+
# 配置codeserver的语言和扩展
|
| 42 |
+
COPY settings.json /home/coder/.local/share/code-server/User/
|
| 43 |
+
COPY config.yaml /home/coder/.config/code-server/
|
| 44 |
+
COPY create_languagepacks.sh /home/
|
| 45 |
COPY cph-ng-0.5.5.vsix /home/
|
| 46 |
COPY vscode-luogu.vsix /home/
|
| 47 |
+
RUN code-server --install-extension /home/cph-ng-0.5.5.vsix && \
|
| 48 |
+
code-server --install-extension /home/vscode-luogu.vsix && \
|
| 49 |
+
code-server --install-extension ms-ceintl.vscode-language-pack-zh-hans && \
|
| 50 |
+
code-server --install-extension hediet.vscode-drawio && \
|
| 51 |
+
code-server --install-extension formulahendry.code-runner && \
|
| 52 |
+
code-server --install-extension llvm-vs-code-extensions.vscode-clangd && \
|
| 53 |
+
/home/create_languagepacks.sh
|
| 54 |
+
|
| 55 |
+
#配置git
|
| 56 |
+
RUN git config --global user.name "Save-it" && \
|
| 57 |
+
git config --global user.email "lin2011746853@outlook.com" && \
|
| 58 |
+
git config --global credential.helper store && \
|
| 59 |
+
git config --global credential.https://Save-it@github.com.username Save-it && \
|
| 60 |
+
git config --global credential.https://Save-it@github.com.password ${GH_TOKEN} && \
|
| 61 |
+
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 |
+
# 暴露端口
|
| 65 |
EXPOSE 8080
|
| 66 |
EXPOSE 7860
|
|
|
|
| 67 |
|
| 68 |
# 将启动脚本设为容器入口
|
| 69 |
CMD ["/start.sh"]
|