# Use an official Ubuntu runtime as a parent image FROM ubuntu:latest # 设置非交互式环境变量,以避免 tzdata 安装时的交互 ENV DEBIAN_FRONTEND=noninteractive # Use Aliyun mirrors for apt-get RUN sed -i 's/http:\/\/archive.ubuntu.com\/ubuntu\//http:\/\/mirrors.aliyun.com\/ubuntu\//g' /etc/apt/sources.list # Update the package lists RUN apt-get update # Install build tools RUN apt-get install -y g++ make cmake autoconf automake libtool # 安装 spdlog 依赖 RUN apt-get install -y \ libfmt-dev # Download and build libhv from source RUN apt-get install -y git RUN git clone https://github.com/ithewei/libhv.git /usr/src/libhv WORKDIR /usr/src/libhv RUN make RUN make install # Add the libhv library path RUN ldconfig # 克隆 spdlog 仓库 RUN git clone https://github.com/gabime/spdlog.git /usr/src/spdlog WORKDIR /usr/src/spdlog # 运行 CMake 配置 RUN cmake . # 运行构建 RUN make # 运行安装 RUN make install RUN ldconfig # Set the working directory to /app WORKDIR /app # Copy the source code into the container COPY . . RUN apt-get install -y tzdata # 设置时区为 Asia/Shanghai ENV TZ=Asia/Shanghai RUN dpkg-reconfigure --frontend noninteractive tzdata # Compile the C++ program RUN g++ -std=c++14 -g -o proxyServer src/*.cpp main.cpp -I include -lhv -lspdlog EXPOSE 8080 # Run my_program when the container launches CMD ["./proxyServer"]