From cd12c244bb0acdf6a475f99f3f7fefc5cac805e2 Mon Sep 17 00:00:00 2001 From: fantasy-peak <82742316+fantasy-peak@users.noreply.github.com> Date: Thu, 16 Nov 2023 09:54:03 +0800 Subject: [PATCH] Add rockylinux Dockerfile && Update Dockerfile (#348) * Update Dockerfile * Add rockylinux Dockerfile --- README.md | 22 +++------------------- README_CN.md | 22 +++------------------- docker/centos7/Dockerfile | 12 +++++++++--- docker/rockylinux/Dockerfile | 19 +++++++++++++++++++ docker/ubuntu/Dockerfile | 27 +++++++++++++++++---------- 5 files changed, 51 insertions(+), 51 deletions(-) create mode 100644 docker/rockylinux/Dockerfile diff --git a/README.md b/README.md index 43c32f42c..1ca436633 100644 --- a/README.md +++ b/README.md @@ -174,26 +174,10 @@ bazel build --copt='-O0' --copt='-ggdb' ... # Docker Compile Environment ``` -# for centos-7 git clone https://github.com/alibaba/async_simple.git -cd async_simple/docker/centos7 -docker build . --no-cache -t async_simple:1.0 --network host -docker run -it --name test-async-simple async_simple:1.0 /bin/bash -// Has entered centos bash shell -mkdir build && cd build -cmake3 .. -DCMAKE_BUILD_TYPE=Release - -# for ubuntu 22.04 -git clone https://github.com/alibaba/async_simple.git -cd async_simple/docker/ubuntu -docker build . --no-cache -t async_simple:1.0 --network host -docker run -it --name test-async-simple async_simple:1.0 /bin/bash -// Has entered ubuntu bash shell -mkdir build && cd build -# use clang for compile -CXX=clang++-13 CC=clang-13 cmake .. -DCMAKE_BUILD_TYPE=Release -# use g++ for compile -CXX=g++-11 CC=gcc-11 cmake .. -DCMAKE_BUILD_TYPE=Release +cd async_simple/docker/(ubuntu|centos7|rockylinux) +docker build . --no-cache -t async_simple:1.0 +docker run -it --name async_simple async_simple:1.0 /bin/bash ``` # Get Started diff --git a/README_CN.md b/README_CN.md index 79612c470..a4968f873 100644 --- a/README_CN.md +++ b/README_CN.md @@ -167,26 +167,10 @@ bazel build --copt='-O0' --copt='-ggdb' ... # Docker 编译环境 ``` -# 使用 centos-7 git clone https://github.com/alibaba/async_simple.git -cd async_simple/docker/centos7 -docker build . --no-cache -t async_simple:1.0 --network host -docker run -it --name test-async-simple async_simple:1.0 /bin/bash -// 已经进入 centos bash shell -mkdir build && cd build -cmake3 .. -DCMAKE_BUILD_TYPE=Release - -# 使用 ubuntu 22.04 -git clone https://github.com/alibaba/async_simple.git -cd async_simple/docker/ubuntu -docker build . --no-cache -t async_simple:1.0 --network host -docker run -it --name test-async-simple async_simple:1.0 /bin/bash -// 已经进入 ubuntu bash shell -mkdir build && cd build -# 使用 clang 编译 -CXX=clang++-13 CC=clang-13 cmake .. -DCMAKE_BUILD_TYPE=Release -# 使用 g++ 编译 -CXX=g++-11 CC=gcc-11 cmake .. -DCMAKE_BUILD_TYPE=Release +cd async_simple/docker/(ubuntu|centos7|rockylinux) +docker build . --no-cache -t async_simple:1.0 +docker run -it --name async_simple async_simple:1.0 /bin/bash ``` # 更多示例 diff --git a/docker/centos7/Dockerfile b/docker/centos7/Dockerfile index d2c1c7ec0..a1001ce3d 100644 --- a/docker/centos7/Dockerfile +++ b/docker/centos7/Dockerfile @@ -5,12 +5,18 @@ ENV TZ=Asia/Shanghai RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone WORKDIR /root + RUN yum update --nogpgcheck -y \ && yum install --nogpgcheck -y epel-release centos-release-scl \ && yum install --nogpgcheck -y devtoolset-11-gcc-c++ libaio-devel.x86_64 git cmake3 RUN echo "source /opt/rh/devtoolset-11/enable" >> .bashrc -ENV ASYNC_SIMPLE_ROOT="/root/async_simple" -RUN git clone https://github.com/alibaba/async_simple.git $ASYNC_SIMPLE_ROOT -WORKDIR $ASYNC_SIMPLE_ROOT +RUN git clone https://github.com/alibaba/async_simple.git \ + && source /opt/rh/devtoolset-11/enable \ + && cd async_simple \ + && mkdir build && cd build \ + && cmake3 .. -DCMAKE_BUILD_TYPE=Release -DASYNC_SIMPLE_ENABLE_TESTS=OFF \ + && make -j 9 + +WORKDIR /root/async_simple diff --git a/docker/rockylinux/Dockerfile b/docker/rockylinux/Dockerfile new file mode 100644 index 000000000..1c06c3aaf --- /dev/null +++ b/docker/rockylinux/Dockerfile @@ -0,0 +1,19 @@ +FROM rockylinux:9.2 + +WORKDIR /root + +RUN dnf update -y \ + && dnf install -y cmake.x86_64 git.x86_64 clang.x86_64 libaio-devel.x86_64 gcc.x86_64 gcc-c++.x86_64 + +RUN git clone https://github.com/alibaba/async_simple.git +RUN cd async_simple \ + && mkdir clang_build && cd clang_build \ + && CXX=clang++ CC=clang cmake .. -DCMAKE_BUILD_TYPE=Release -DASYNC_SIMPLE_ENABLE_TESTS=OFF \ + && make -j 9 + +RUN cd async_simple \ + && mkdir gcc_build && cd gcc_build \ + && cmake .. -DCMAKE_BUILD_TYPE=Release \ + && make -j 9 && ctest + +WORKDIR /root/async_simple diff --git a/docker/ubuntu/Dockerfile b/docker/ubuntu/Dockerfile index d0995a7ce..3a18452ab 100644 --- a/docker/ubuntu/Dockerfile +++ b/docker/ubuntu/Dockerfile @@ -1,16 +1,23 @@ FROM ubuntu:22.04 -ENV TZ=UTC -RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone -ENV LANG=en_US.UTF-8 \ - LANGUAGE=en_US:en \ - LC_ALL=en_US.UTF-8 - WORKDIR /root RUN apt-get update -y \ - && apt-get install -y cmake git clang-13 libaio-dev libgtest-dev libgmock-dev gcc-11 g++-11 + && apt-get install -y cmake git clang-13 libaio-dev libgtest-dev libgmock-dev gcc-12 g++-12 \ + && update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 100 \ + && update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 100 \ + && update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-13 100 \ + && update-alternatives --install /usr/bin/clang clang /usr/bin/clang-13 100 + +RUN git clone https://github.com/alibaba/async_simple.git +RUN cd async_simple \ + && mkdir clang_build && cd clang_build \ + && CXX=clang++ CC=clang cmake .. -DCMAKE_BUILD_TYPE=Release \ + && make -j 9 && ctest + +RUN cd async_simple \ + && mkdir gcc_build && cd gcc_build \ + && cmake .. -DCMAKE_BUILD_TYPE=Release \ + && make -j 9 && ctest -ENV ASYNC_SIMPLE_ROOT="/root/async_simple" -RUN git clone https://github.com/alibaba/async_simple.git $ASYNC_SIMPLE_ROOT -WORKDIR $ASYNC_SIMPLE_ROOT +WORKDIR /root/async_simple