diff --git a/.github/workflows/build-images.yml b/.github/workflows/build-images.yml index 75538ad..d12e445 100644 --- a/.github/workflows/build-images.yml +++ b/.github/workflows/build-images.yml @@ -4,6 +4,9 @@ on: push: tags: - v* + pull_request: + branches: + - master jobs: build: diff --git a/Dockerfile b/Dockerfile index 06dc5d5..dd7d055 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,10 @@ -FROM rust:1.61-buster as builder +# Needed for rust cross compilation helper scripts. +# https://github.com/tonistiigi/xx#rust +FROM --platform=$BUILDPLATFORM tonistiigi/xx AS xx + +FROM --platform=$BUILDPLATFORM rust:1.61-buster as builder + +COPY --from=xx / / ENV CARGO_NET_GIT_FETCH_WITH_CLI=true @@ -9,8 +15,13 @@ COPY proxy/ ./proxy COPY mongo-protocol/ ./mongo-protocol COPY async-bson/ ./async-bson -RUN cargo build --release +RUN apt-get update && apt-get install -y clang lld + RUN cargo test --release +ARG TARGETPLATFORM + +RUN xx-apt-get install -y xx-c-essentials +RUN xx-cargo build --release --target-dir ./ FROM debian:buster-slim @@ -21,7 +32,7 @@ RUN adduser --uid 9999 --disabled-password --gecos '' mongoproxy USER mongoproxy WORKDIR /mongoproxy -COPY --from=builder /build/mongoproxy/target/release/mongoproxy ./ +COPY --from=builder /build/mongoproxy/*/release/mongoproxy ./ COPY iptables-init.sh . ENV MALLOC_ARENA_MAX 2