From e3fcf37afe4c53c657b1ecdeabd22716947a82c6 Mon Sep 17 00:00:00 2001 From: krahets Date: Fri, 1 Dec 2023 20:47:19 +0800 Subject: [PATCH] python c++ c --- codes/Dockerfile | 22 ++++++++++++---------- codes/devcontainer.json | 8 ++++++++ codes/docker-compose.yml | 4 +++- 3 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 codes/devcontainer.json diff --git a/codes/Dockerfile b/codes/Dockerfile index 97d37bbcf..b08510dda 100644 --- a/codes/Dockerfile +++ b/codes/Dockerfile @@ -5,31 +5,33 @@ RUN sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list && sed -i 's/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list && \ sed -i 's/ports.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list -RUN apt-get update && apt-get install -y wget - # Install languages environment ARG LANGS RUN for LANG in $LANGS; do \ case $LANG in \ python) \ - apt-get install -y python3.10 && \ + apt-get update && apt-get install -y python3.10 && \ update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1 ;; \ cpp) \ - apt-get install -y g++ gdb ;; \ + apt-get update && apt-get install -y g++ gdb ;; \ java) \ - apt-get install -y openjdk-17-jdk ;; \ + apt-get update && apt-get install -y openjdk-17-jdk ;; \ csharp) \ - wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb && \ - dpkg -i packages-microsoft-prod.deb && \ - apt-get update && \ - apt-get install -y dotnet-sdk-8.0 ;; \ + apt-get update && apt-get install -y wget && \ + wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh && \ + chmod +x ./dotnet-install.sh && \ + ./dotnet-install.sh --channel 8.0 && \ + apt-get install libicu-dev ;; \ + c) \ + apt-get update && apt-get install -y gcc gdb ;; \ # More languages... *) \ echo "Warning: No installation workflow for $LANG" ;; \ esac \ done +RUN rm -rf /var/lib/apt/lists/* + WORKDIR /codes -COPY ./ ./ CMD ["/bin/bash"] diff --git a/codes/devcontainer.json b/codes/devcontainer.json new file mode 100644 index 000000000..8b0ab3628 --- /dev/null +++ b/codes/devcontainer.json @@ -0,0 +1,8 @@ +{ + "name": "hello-algo-code", + "extensions": [ + "ms-python.python", + "ms-vscode.cpptools", + // List other extensions you want + ] +} \ No newline at end of file diff --git a/codes/docker-compose.yml b/codes/docker-compose.yml index 7c11b7c5b..48ad0f231 100644 --- a/codes/docker-compose.yml +++ b/codes/docker-compose.yml @@ -6,8 +6,10 @@ services: args: # 设置需要安装的语言,使用空格隔开 # Set the languages to be installed, separated by spaces - LANGS: "python cpp java csharp" + LANGS: "python cpp c" image: hello-algo-code container_name: hello-algo-code + volumes: + - .:/codes stdin_open: true tty: true