Dockerfile 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # This Dockerfile is composed of two steps: the first one builds the release
  2. # binary, and then the binary is copied inside another, empty image.
  3. #################
  4. # Build image #
  5. #################
  6. FROM ubuntu:22.04 as build
  7. # For CI/CD purposes, we can pass a pre-run command to the build image
  8. ARG PRE_RUN_CMD=""
  9. RUN $PRE_RUN_CMD
  10. RUN apt-get update -y && \
  11. DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
  12. g++ \
  13. curl \
  14. ca-certificates \
  15. libc6-dev \
  16. make \
  17. libssl-dev \
  18. pkg-config \
  19. git \
  20. cmake \
  21. zlib1g-dev
  22. RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- \
  23. --default-toolchain stable --profile minimal -y
  24. COPY . .
  25. RUN bash -c 'source $HOME/.cargo/env && cargo test --release --all'
  26. RUN bash -c 'source $HOME/.cargo/env && cargo build --release'
  27. ##################
  28. # Output image #
  29. ##################
  30. FROM ubuntu:22.04 AS binary
  31. RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
  32. ca-certificates
  33. RUN mkdir -p /opt/triagebot
  34. COPY --from=build /target/release/triagebot /usr/local/bin/
  35. COPY templates /opt/triagebot/templates
  36. WORKDIR /opt/triagebot
  37. ENV PORT=80
  38. CMD triagebot