From 0339d099b8661ded4253693ff1b74dbb78f12af0 Mon Sep 17 00:00:00 2001 From: Tim Geoghegan Date: Wed, 23 Sep 2020 15:39:28 -0700 Subject: [PATCH] facilitator Dockerfile Adds a Dockerfile that builds the facilitator in a minimal Alpine Linux container, then packages the statically linked binary into another Alpine Linux container. Also adds a `docker build` step to CI build. --- .github/workflows/ci-build.yml | 17 +++++++++++++---- facilitator/Dockerfile | 16 ++++++++++++++++ facilitator/README.md | 6 +++++- facilitator/src/bin/{main.rs => facilitator.rs} | 0 4 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 facilitator/Dockerfile rename facilitator/src/bin/{main.rs => facilitator.rs} (100%) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 2d82f30dc..85caeaf57 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -10,12 +10,11 @@ on: env: CARGO_TERM_COLOR: always -defaults: - run: - working-directory: facilitator - jobs: build-rust: + defaults: + run: + working-directory: facilitator runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -25,3 +24,13 @@ jobs: run: cargo build --verbose - name: Run tests run: cargo test --verbose + docker: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Docker build + uses: docker/setup-buildx-action@v1 + - name: build + uses: docker/build-push-action@v2 + with: + file: facilitator/Dockerfile diff --git a/facilitator/Dockerfile b/facilitator/Dockerfile new file mode 100644 index 000000000..63d0de135 --- /dev/null +++ b/facilitator/Dockerfile @@ -0,0 +1,16 @@ +FROM rust:1.46-alpine as builder + +RUN apk add libc-dev && apk update + +WORKDIR /usr/src/prio-server +# We enumerate these paths so that `docker build` fails in an obvious way if run +# from the wrong place. +COPY ./avro-schema ./avro-schema +COPY ./facilitator ./facilitator + +RUN cargo install --path ./facilitator + +FROM rust:1.46-alpine +RUN apk update +COPY --from=builder /usr/local/cargo/bin/facilitator /usr/local/bin/facilitator +ENTRYPOINT ["/usr/local/bin/facilitator"] diff --git a/facilitator/README.md b/facilitator/README.md index 482b8c866..b6b651828 100644 --- a/facilitator/README.md +++ b/facilitator/README.md @@ -4,12 +4,16 @@ This is ISRG's implementation of a Prio accumulation server. It ingests a share ## Getting started -[Install a Rust toolchain](https://www.rust-lang.org/tools/install), then just `cargo build|run|test`. +[Install a Rust toolchain](https://www.rust-lang.org/tools/install), then just `cargo build|run|test`. See `cargo run -- --help` for information on the various options and subcommands. ## Generating ingestion data To generate sample ingestion data, see the `generate-ingestion-sample` command and its usage (`cargo run -- generate-ingestion-sample --help`). +## Docker + +To build a Docker image, try `docker build -t my-image-repository/facilitator:x.y.z -f facilitator/Dockerfile .` *from the root directory of `prio-server`*. This is important because building `facilitator` depends on the schema files in `avro-schema`. + ## References [Prio Data Share Batch IDL](https://docs.google.com/document/d/1L06dpE7OcC4CXho2UswrfHrnWKtbA9aSSmO_5o7Ku6I/edit#heading=h.3kq1yexquq2g) diff --git a/facilitator/src/bin/main.rs b/facilitator/src/bin/facilitator.rs similarity index 100% rename from facilitator/src/bin/main.rs rename to facilitator/src/bin/facilitator.rs