| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 | # This Dockerfile is composed of two steps: the first one builds the release# binary, and then the binary is copied inside another, empty image.##################  Build image  ##################FROM ubuntu:22.04 as build# For CI/CD purposes, we can pass a pre-run command to the build imageARG PRE_RUN_CMD="echo pre-run-cmd"ARG APT_REPO="cn.archive.ubuntu.com"ENV RUSTUP_DIST_SERVER="https://rsproxy.cn"ENV RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup"# 用于在CICD系统中执行自定义命令RUN $PRE_RUN_CMDRUN bash -c "sed -i 's/archive.ubuntu.com/${APT_REPO}/g' /etc/apt/sources.list"RUN apt-get update -y && \    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \      g++ \      curl \      ca-certificates \      libc6-dev \      make \      libssl-dev \      pkg-config \      git \      cmake \      zlib1g-devRUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- \    --default-toolchain stable --profile minimal -yCOPY . .RUN cp ./docker/cargo.confg $HOME/.cargo/configRUN bash -c 'source $HOME/.cargo/env && cargo test --release --all'RUN bash -c 'source $HOME/.cargo/env && cargo build --release'###################  Output image  ###################FROM ubuntu:22.04 AS binaryRUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \    ca-certificatesRUN mkdir -p /opt/triagebotCOPY --from=build /target/release/triagebot /usr/local/bin/COPY templates /opt/triagebot/templatesWORKDIR /opt/triagebotENV PORT=80CMD triagebot
 |