codeserver / Dockerfile
LAST233's picture
Update Dockerfile
0345ced verified
FROM ubuntu:22.04
# 系统变量
ENV LANG C.UTF-8
ENV LANGUAGE C.UTF-8
ENV TZ=Asia/Shanghai
# 安装基础依赖和code-server
RUN apt-get update && apt-get install -y && \
DEBIAN_FRONTEND=noninteractive apt-get install gcc g++ gdb clangd wget git curl jq tzdata cron rsync -y && \
curl -fsSL https://code-server.dev/install.sh | sh
COPY settings.json /root/.local/share/code-server/User/
COPY config.yaml /root/.config/code-server/
COPY create_languagepacks.sh /home/
COPY cph-ng-0.5.5.vsix /home/
COPY vscode-luogu.vsix /home/
RUN chmod +x /home/create_languagepacks.sh
# 配置git自动提交
COPY autocommit.sh /usr/scripts/autocommit.sh
RUN chmod +x /usr/scripts/autocommit.sh
RUN echo "0 0,6,12,18 * * * root /bin/bash /usr/scripts/autocommit.sh" > /etc/cron.d/autocommit-cron
RUN chmod 0644 /etc/cron.d/autocommit-cron
# 设置工作目录和用户
WORKDIR /home/
# 配置codeserver的语言和扩展
RUN code-server --install-extension /home/cph-ng-0.5.5.vsix && \
code-server --install-extension /home/vscode-luogu.vsix && \
code-server --install-extension ms-ceintl.vscode-language-pack-zh-hans && \
code-server --install-extension hediet.vscode-drawio && \
code-server --install-extension formulahendry.code-runner && \
code-server --install-extension llvm-vs-code-extensions.vscode-clangd
RUN /home/create_languagepacks.sh
RUN --mount=type=secret,id=GH_TOKEN,mode=0444,required=true \
--mount=type=secret,id=GH_USERNAME,mode=0444,required=true \
--mount=type=secret,id=REPO_NAME,mode=0444,required=true \
--mount=type=secret,id=GH_EMAIL,mode=0444,required=true \
git config --global user.name $(cat /run/secrets/GH_USERNAME) && \
git config --global user.email $(cat /run/secrets/GH_EMAIL) && \
git clone -b main https://$(cat /run/secrets/GH_TOKEN)@github.com/$(cat /run/secrets/GH_USERNAME)/$(cat /run/secrets/REPO_NAME).git /home/cpp_competition
RUN echo "#!/bin/bash \n \
cron -n & \
exec code-server /home/cpp_competition" > /home/start.sh
RUN chmod +x /home/start.sh
# 暴露端口
EXPOSE 8080
EXPOSE 7860
# 将启动脚本设为容器入口
CMD ["/home/start.sh"]