diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 607d154..fb0028d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,13 +26,13 @@ env: jobs: build: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Build Dockerfile - run: docker build . --file Dockerfile --tag image + run: docker build . --file Dockerfile --tag image --platform linux/amd64,linux/arm64 - run: | docker run --rm -t -v $PWD:/volume image cp /app/$HANDLER_NAME /volume/handler diff --git a/Cross.toml b/Cross.toml new file mode 100644 index 0000000..2e4efc7 --- /dev/null +++ b/Cross.toml @@ -0,0 +1,9 @@ +[target.aarch64-unknown-linux-gnu] +pre-build = [ + "apt update && apt install -y protobuf-compiler" +] + +[target.x86_64-unknown-linux-gnu] +pre-build = [ + "apt update && apt install -y protobuf-compiler" +] \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index cb523ab..09ba707 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,6 @@ FROM clux/muslrust:stable as builder -ARG PROTOC_VERSION=3.20.2 - -RUN apt-get update && apt-get install -y openssl unzip - -# Install protoc -RUN curl -sSL -o /tmp/protoc.zip "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip" && unzip /tmp/protoc.zip -d /usr/local && rm /tmp/protoc.zip +RUN apt-get update && apt-get install -y openssl unzip protobuf-compiler WORKDIR /src @@ -13,29 +8,27 @@ WORKDIR /src RUN USER=root cargo init --bin --name bender COPY ./Cargo.lock . COPY ./Cargo.toml . -RUN cargo build --release --locked && rm -rf target/x86_64-unknown-linux-musl/release/deps/bender* +RUN cargo build --release --locked && rm -rf target/*/release/deps/bender* RUN rm src/*.rs # Add the source code COPY . . # Run the test suite -RUN cargo test --release && rm -rf target/x86_64-unknown-linux-musl/release/deps/bender* +RUN cargo test --release && rm -rf target/*/release/deps/bender* # Build the final executable of the project RUN cargo build --release --bin bender --locked # Ensure that the binary is at a known location for the next stage RUN mkdir /out && \ - rm /src/target/x86_64-unknown-linux-musl/release/deps/bender*.d && \ - cp /src/target/x86_64-unknown-linux-musl/release/deps/bender* /out/bender - -FROM alpine:latest + rm /src/target/*/release/deps/bender*.d && \ + cp /src/target/*/release/deps/bender* /out/bender -RUN apk --no-cache add ca-certificates +FROM cgr.dev/chainguard/static:latest COPY --from=builder /out/bender /app/bender ADD ./quotes.json /app/quotes.json WORKDIR /app -CMD [ "/app/bender" ] \ No newline at end of file +ENTRYPOINT [ "/app/bender" ] \ No newline at end of file