浏览代码

Roll everything into the docker build

This avoids installing Rust twice, as well as moves the apt dependency
installation to a pre-packaged rust base image in Docker.
Mark Rousskov 5 年之前
父节点
当前提交
56c075d68a
共有 2 个文件被更改,包括 5 次插入24 次删除
  1. 1 7
      .github/workflows/ci.yml
  2. 4 17
      Dockerfile

+ 1 - 7
.github/workflows/ci.yml

@@ -18,13 +18,7 @@ jobs:
         with:
           fetch-depth: 1
 
-      - name: Install Rust
-        run: rustup update stable && rustup default stable
-
-      - name: Run the test suite
-        run: cargo test
-
-      - name: Build the Docker container
+      - name: Test and build
         run: docker build -t triagebot .
 
       - name: Deploy to production

+ 4 - 17
Dockerfile

@@ -5,23 +5,10 @@
 #  Build image  #
 #################
 
-FROM ubuntu:bionic AS build
+FROM rust:1.42 AS build
 
-RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
-    --no-install-recommends \
-    ca-certificates \
-    curl \
-    gcc g++ \
-    pkg-config \
-    libssl-dev
-
-RUN curl https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init >/tmp/rustup-init && \
-    chmod +x /tmp/rustup-init && \
-    /tmp/rustup-init -y --no-modify-path --default-toolchain stable --profile minimal
-ENV PATH=/root/.cargo/bin:$PATH
-
-WORKDIR /tmp/source
-COPY . /tmp/source/
+COPY . .
+RUN cargo test --release --all
 RUN cargo build --release
 
 ##################
@@ -33,6 +20,6 @@ FROM ubuntu:bionic AS binary
 RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
     ca-certificates
 
-COPY --from=build /tmp/source/target/release/triagebot /usr/local/bin/
+COPY --from=build /target/release/triagebot /usr/local/bin/
 ENV PORT=80
 CMD triagebot