diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3083e4cd1..36f6054d6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -205,6 +205,22 @@ jobs: - { target: thumbv7em-none-eabihf, os: ubuntu-latest, std: 1 } - { target: thumbv7m-none-eabi, os: ubuntu-latest, std: 1 } + build-cross: + name: Build Cross + runs-on: ubuntu-latest + needs: [shellcheck, test, generate-matrix, check] + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/setup-rust + + - name: Build xtask + run: cargo build -p xtask + + - name: Build Docker image + id: build-docker-image + timeout-minutes: 15 + run: cargo xtask build-docker-image cross + build: name: target (${{ matrix.pretty }},${{ matrix.os }}) runs-on: ${{ matrix.os }} @@ -309,7 +325,7 @@ jobs: shell: bash publish: - needs: [build, check] + needs: [build, check, build-cross] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b46ba777..884aa1cbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] - ReleaseDate +### Added + +- #878 - added a dockerfile containing cross. + ### Changed - #869 - ensure cargo configuration environment variable flags are passed to the docker container. diff --git a/docker/Dockerfile.cross b/docker/Dockerfile.cross new file mode 100644 index 000000000..9c036480e --- /dev/null +++ b/docker/Dockerfile.cross @@ -0,0 +1,11 @@ +FROM docker:20.10-dind + +RUN apk add curl bash libgcc gcc musl-dev git + +RUN curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y +# need to ensure cargo is in the path when we run this command, +# since we won't be sourcing the profile. +RUN PATH="$HOME/.cargo/bin:$PATH" cargo install cross --git https://github.com/cross-rs/cross --locked + +COPY cross-entry.sh / +ENTRYPOINT ["/cross-entry.sh"] diff --git a/docker/cross-entry.sh b/docker/cross-entry.sh new file mode 100755 index 000000000..08c51f969 --- /dev/null +++ b/docker/cross-entry.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +# shellcheck disable=SC1090 +. ~/.cargo/env +export CROSS_CONTAINER_IN_CONTAINER=1 + +exec "${@}" diff --git a/docker/cross.sh b/docker/cross.sh new file mode 100755 index 000000000..6e3e5b9de --- /dev/null +++ b/docker/cross.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +main() { + apk add gcc curl musl-dev + + curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + PATH="$HOME/.cargo/bin:$PATH" cargo install cross --git https://github.com/cross-rs/cross --locked + + apk del gcc curl musl-dev + + rm -rf "${0}" +} + +main "${@}"