From e00243f81f6e0d180b588d6368dfc3dbec0ac8fc Mon Sep 17 00:00:00 2001 From: wileyj <2847772+wileyj@users.noreply.github.com> Date: Thu, 29 Feb 2024 11:42:26 -0800 Subject: [PATCH 1/6] conditionally exclude some crates when target os is windows or macos --- .../workflows/create-source-binary-x64.yml | 78 ------------------- clarity/Cargo.toml | 2 +- libsigner/Cargo.toml | 4 +- libstackerdb/Cargo.toml | 4 +- stacks-common/Cargo.toml | 4 +- stackslib/Cargo.toml | 6 +- stackslib/src/main.rs | 4 +- testnet/stacks-node/Cargo.toml | 2 +- testnet/stacks-node/src/main.rs | 4 +- 9 files changed, 15 insertions(+), 93 deletions(-) delete mode 100644 .github/workflows/create-source-binary-x64.yml diff --git a/.github/workflows/create-source-binary-x64.yml b/.github/workflows/create-source-binary-x64.yml deleted file mode 100644 index a1b435aa5f..0000000000 --- a/.github/workflows/create-source-binary-x64.yml +++ /dev/null @@ -1,78 +0,0 @@ -## Github workflow to create multiarch binaries from source - -name: Create Binaries for x86_64 - -on: - workflow_call: - inputs: - tag: - description: "Tag name of this release (x.y.z)" - required: true - type: string - arch: - description: "Stringified JSON object listing of platform matrix" - required: false - type: string - default: >- - ["linux-glibc-x64", "linux-musl-x64", "macos-x64", "windows-x64"] - cpu: - description: "Stringified JSON object listing of target CPU matrix" - required: false - type: string - default: >- - ["x86-64", "x86-64-v3"] - -## change the display name to the tag being built -run-name: ${{ inputs.tag }} - -concurrency: - group: create-binary-${{ github.head_ref || github.ref || github.run_id}} - ## Only cancel in progress if this is for a PR - cancel-in-progress: ${{ github.event_name == 'pull_request' }} - -jobs: - ## Runs when the following is true: - ## - tag is provided - ## - workflow is building default branch (master) - artifact: - if: | - inputs.tag != '' && - github.ref == format('refs/heads/{0}', github.event.repository.default_branch) - name: Build Binaries - runs-on: ubuntu-latest - strategy: - ## Run a maximum of 10 builds concurrently, using the matrix defined in inputs.arch - max-parallel: 10 - matrix: - platform: ${{ fromJson(inputs.arch) }} - cpu: ${{ fromJson(inputs.cpu) }} - steps: - ## Setup Docker for the builds - - name: Docker setup - uses: stacks-network/actions/docker@main - - ## Build the binaries using defined dockerfiles - - name: Build Binary (${{ matrix.platform }}_${{ matrix.cpu }}) - id: build_binaries - uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # 5.0.0 - with: - file: build-scripts/Dockerfile.${{ matrix.platform }} - outputs: type=local,dest=./release/${{ matrix.platform }} - build-args: | - STACKS_NODE_VERSION=${{ inputs.tag || env.GITHUB_SHA_SHORT }} - OS_ARCH=${{ matrix.platform }} - TARGET_CPU=${{ matrix.cpu }} - GIT_BRANCH=${{ env.GITHUB_REF_SHORT }} - GIT_COMMIT=${{ env.GITHUB_SHA_SHORT }} - - ## Compress the binary artifact - - name: Compress artifact - id: compress_artifact - run: zip --junk-paths ${{ matrix.platform }}_${{ matrix.cpu }} ./release/${{ matrix.platform }}/* - - ## Upload the binary artifact to the github action (used in `github-release.yml` to create a release) - - name: Upload artifact - id: upload_artifact - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 - with: - path: ${{ matrix.platform }}_${{ matrix.cpu }}.zip diff --git a/clarity/Cargo.toml b/clarity/Cargo.toml index c0b82a7fd1..f6a5c70cbf 100644 --- a/clarity/Cargo.toml +++ b/clarity/Cargo.toml @@ -56,6 +56,6 @@ developer-mode = [] slog_json = ["stacks_common/slog_json"] testing = [] -[target.'cfg(all(target_arch = "x86_64", not(target_env = "msvc")))'.dependencies] +[target.'cfg(all(target_arch = "x86_64", not(any(target_os="windows"))))'.dependencies] sha2-asm = "0.5.3" diff --git a/libsigner/Cargo.toml b/libsigner/Cargo.toml index 4b1f21eef7..e04dcbbdc1 100644 --- a/libsigner/Cargo.toml +++ b/libsigner/Cargo.toml @@ -44,8 +44,8 @@ features = ["arbitrary_precision", "unbounded_depth"] version = "0.24.3" features = ["serde", "recovery"] -[target.'cfg(all(any(target_arch = "x86_64", target_arch = "x86", target_arch = "aarch64"), not(target_env = "msvc")))'.dependencies] +[target.'cfg(all(any(target_arch = "x86_64", target_arch = "x86", target_arch = "aarch64"), not(any(target_os="windows"))))'.dependencies] sha2 = { version = "0.10", features = ["asm"] } -[target.'cfg(any(not(any(target_arch = "x86_64", target_arch = "x86", target_arch = "aarch64")), target_env = "msvc"))'.dependencies] +[target.'cfg(any(not(any(target_arch = "x86_64", target_arch = "x86", target_arch = "aarch64")), any(target_os = "windows")))'.dependencies] sha2 = { version = "0.10" } diff --git a/libstackerdb/Cargo.toml b/libstackerdb/Cargo.toml index 53cf128edc..0d54de5428 100644 --- a/libstackerdb/Cargo.toml +++ b/libstackerdb/Cargo.toml @@ -26,8 +26,8 @@ clarity = { path = "../clarity" } version = "0.24.3" features = ["serde", "recovery"] -[target.'cfg(all(any(target_arch = "x86_64", target_arch = "x86", target_arch = "aarch64"), not(target_env = "msvc")))'.dependencies] +[target.'cfg(all(any(target_arch = "x86_64", target_arch = "x86", target_arch = "aarch64"), not(any(target_os="windows"))))'.dependencies] sha2 = { version = "0.10", features = ["asm"] } -[target.'cfg(any(not(any(target_arch = "x86_64", target_arch = "x86", target_arch = "aarch64")), target_env = "msvc"))'.dependencies] +[target.'cfg(any(not(any(target_arch = "x86_64", target_arch = "x86", target_arch = "aarch64")), any(target_os = "windows")))'.dependencies] sha2 = { version = "0.10" } diff --git a/stacks-common/Cargo.toml b/stacks-common/Cargo.toml index 50eadfb85d..d9f987f574 100644 --- a/stacks-common/Cargo.toml +++ b/stacks-common/Cargo.toml @@ -78,8 +78,8 @@ developer-mode = [] slog_json = ["slog-json"] testing = [] -[target.'cfg(all(any(target_arch = "x86_64", target_arch = "x86", target_arch = "aarch64"), not(target_env = "msvc")))'.dependencies] +[target.'cfg(all(any(target_arch = "x86_64", target_arch = "x86", target_arch = "aarch64"), not(any(target_os="windows"))))'.dependencies] sha2 = { version = "0.10", features = ["asm"] } -[target.'cfg(any(not(any(target_arch = "x86_64", target_arch = "x86", target_arch = "aarch64")), target_env = "msvc"))'.dependencies] +[target.'cfg(any(not(any(target_arch = "x86_64", target_arch = "x86", target_arch = "aarch64")), any(target_os="windows")))'.dependencies] sha2 = { version = "0.10" } diff --git a/stackslib/Cargo.toml b/stackslib/Cargo.toml index 8e2c483017..be75337115 100644 --- a/stackslib/Cargo.toml +++ b/stackslib/Cargo.toml @@ -59,7 +59,7 @@ siphasher = "0.3.7" wsts = { workspace = true } hashbrown = { workspace = true } -[target.'cfg(not(target_env = "msvc"))'.dependencies] +[target.'cfg(not(any(target_os = "macos",target_os="windows", target_arch = "arm" )))'.dependencies] tikv-jemallocator = {workspace = true} [target.'cfg(unix)'.dependencies] @@ -114,8 +114,8 @@ monitoring_prom = ["prometheus"] slog_json = ["slog-json", "stacks-common/slog_json", "clarity/slog_json", "pox-locking/slog_json"] testing = [] -[target.'cfg(all(any(target_arch = "x86_64", target_arch = "x86", target_arch = "aarch64"), not(target_env = "msvc")))'.dependencies] +[target.'cfg(all(any(target_arch = "x86_64", target_arch = "x86", target_arch = "aarch64"), not(any(target_os="windows"))))'.dependencies] sha2 = { version = "0.10", features = ["asm"] } -[target.'cfg(any(not(any(target_arch = "x86_64", target_arch = "x86", target_arch = "aarch64")), target_env = "msvc"))'.dependencies] +[target.'cfg(any(not(any(target_arch = "x86_64", target_arch = "x86", target_arch = "aarch64")), any(target_os="windows")))'.dependencies] sha2 = { version = "0.10" } diff --git a/stackslib/src/main.rs b/stackslib/src/main.rs index 652d9bf2dc..0e0f242b00 100644 --- a/stackslib/src/main.rs +++ b/stackslib/src/main.rs @@ -26,10 +26,10 @@ extern crate stacks_common; #[macro_use(o, slog_log, slog_trace, slog_debug, slog_info, slog_warn, slog_error)] extern crate slog; -#[cfg(not(target_env = "msvc"))] +#[cfg(not(any(target_os = "macos", target_os = "windows", target_arch = "arm")))] use tikv_jemallocator::Jemalloc; -#[cfg(not(target_env = "msvc"))] +#[cfg(not(any(target_os = "macos", target_os = "windows", target_arch = "arm")))] #[global_allocator] static GLOBAL: Jemalloc = Jemalloc; diff --git a/testnet/stacks-node/Cargo.toml b/testnet/stacks-node/Cargo.toml index 71f8808a12..72cc8d2491 100644 --- a/testnet/stacks-node/Cargo.toml +++ b/testnet/stacks-node/Cargo.toml @@ -32,7 +32,7 @@ rand = { workspace = true } rand_core = { workspace = true } hashbrown = { workspace = true } -[target.'cfg(not(target_env = "msvc"))'.dependencies] +[target.'cfg(not(any(target_os = "macos", target_os="windows", target_arch = "arm")))'.dependencies] tikv-jemallocator = {workspace = true} [dev-dependencies] diff --git a/testnet/stacks-node/src/main.rs b/testnet/stacks-node/src/main.rs index 29d1fde368..c636535353 100644 --- a/testnet/stacks-node/src/main.rs +++ b/testnet/stacks-node/src/main.rs @@ -43,7 +43,7 @@ use stacks::chainstate::coordinator::{get_next_recipients, OnChainRewardSetProvi use stacks::chainstate::stacks::address::PoxAddress; use stacks::chainstate::stacks::db::blocks::DummyEventDispatcher; use stacks::chainstate::stacks::db::StacksChainState; -#[cfg(not(target_env = "msvc"))] +#[cfg(not(any(target_os = "macos", target_os = "windows", target_arch = "arm")))] use tikv_jemallocator::Jemalloc; pub use self::burnchains::{ @@ -60,7 +60,7 @@ use crate::mockamoto::MockamotoNode; use crate::neon_node::{BlockMinerThread, TipCandidate}; use crate::run_loop::boot_nakamoto; -#[cfg(not(target_env = "msvc"))] +#[cfg(not(any(target_os = "macos", target_os = "windows", target_arch = "arm")))] #[global_allocator] static GLOBAL: Jemalloc = Jemalloc; From cef2c2feeb2f150f50326c54ba4402cbbb4ff228 Mon Sep 17 00:00:00 2001 From: wileyj <2847772+wileyj@users.noreply.github.com> Date: Thu, 29 Feb 2024 11:43:49 -0800 Subject: [PATCH 2/6] update binary build dockerfiles to set RUSTFLAG if target-cpu is provided --- build-scripts/Dockerfile.linux-glibc-arm64 | 3 ++- build-scripts/Dockerfile.linux-glibc-armv7 | 3 ++- build-scripts/Dockerfile.linux-glibc-x64 | 6 +++--- build-scripts/Dockerfile.linux-musl-arm64 | 5 ++--- build-scripts/Dockerfile.linux-musl-armv7 | 4 ++-- build-scripts/Dockerfile.linux-musl-x64 | 8 ++++---- build-scripts/Dockerfile.macos-arm64 | 5 ++--- build-scripts/Dockerfile.macos-x64 | 9 ++++----- build-scripts/Dockerfile.windows-x64 | 8 ++++---- 9 files changed, 25 insertions(+), 26 deletions(-) diff --git a/build-scripts/Dockerfile.linux-glibc-arm64 b/build-scripts/Dockerfile.linux-glibc-arm64 index 11e38f8804..2e0587bac6 100644 --- a/build-scripts/Dockerfile.linux-glibc-arm64 +++ b/build-scripts/Dockerfile.linux-glibc-arm64 @@ -21,6 +21,7 @@ RUN --mount=type=tmpfs,target=${BUILD_DIR} cp -R /src/. ${BUILD_DIR}/ \ cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} --bin stacks-node --bin stacks-inspect --bin clarity-cli --bin blockstack-cli \ && mkdir -p /out \ && cp -R ${BUILD_DIR}/target/${TARGET}/release/. /out +# --bin stacks-node --bin stacks-inspect --bin clarity-cli --bin blockstack-cli FROM scratch AS export-stage -COPY --from=build /out/stacks-inspect /out/blockstack-cli /out/clarity-cli /out/stacks-node / +COPY --from=build /out/stacks-inspect /out/blockstack-cli /out/clarity-cli /out/stacks-node / \ No newline at end of file diff --git a/build-scripts/Dockerfile.linux-glibc-armv7 b/build-scripts/Dockerfile.linux-glibc-armv7 index cc05298dfe..c28ca7d972 100644 --- a/build-scripts/Dockerfile.linux-glibc-armv7 +++ b/build-scripts/Dockerfile.linux-glibc-armv7 @@ -21,6 +21,7 @@ RUN --mount=type=tmpfs,target=${BUILD_DIR} cp -R /src/. ${BUILD_DIR}/ \ cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} --bin stacks-node --bin stacks-inspect --bin clarity-cli --bin blockstack-cli \ && mkdir -p /out \ && cp -R ${BUILD_DIR}/target/${TARGET}/release/. /out +# --bin stacks-node --bin stacks-inspect --bin clarity-cli --bin blockstack-cli FROM scratch AS export-stage -COPY --from=build /out/stacks-inspect /out/blockstack-cli /out/clarity-cli /out/stacks-node / +COPY --from=build /out/stacks-inspect /out/blockstack-cli /out/clarity-cli /out/stacks-node / \ No newline at end of file diff --git a/build-scripts/Dockerfile.linux-glibc-x64 b/build-scripts/Dockerfile.linux-glibc-x64 index 0e2bbdd9be..19f2f89c93 100644 --- a/build-scripts/Dockerfile.linux-glibc-x64 +++ b/build-scripts/Dockerfile.linux-glibc-x64 @@ -7,6 +7,7 @@ ARG BUILD_DIR=/build ARG TARGET=x86_64-unknown-linux-gnu # Allow us to override the default `--target-cpu` for the given target triplet ARG TARGET_CPU +ENV RUSTFLAGS="${TARGET_CPU:+${RUSTFLAGS} -Ctarget-cpu=${TARGET_CPU}}" WORKDIR /src COPY . . @@ -17,10 +18,9 @@ RUN apt-get update && apt-get install -y git RUN --mount=type=tmpfs,target=${BUILD_DIR} cp -R /src/. ${BUILD_DIR}/ \ && cd ${BUILD_DIR} \ && rustup target add ${TARGET} \ - ${TARGET_CPU:+RUSTFLAGS="$RUSTFLAGS $TARGET_CPU"} \ - cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} --bin stacks-node --bin stacks-inspect --bin clarity-cli --bin blockstack-cli \ + && cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} --bin stacks-node --bin stacks-inspect --bin clarity-cli --bin blockstack-cli \ && mkdir -p /out \ && cp -R ${BUILD_DIR}/target/${TARGET}/release/. /out FROM scratch AS export-stage -COPY --from=build /out/stacks-inspect /out/blockstack-cli /out/clarity-cli /out/stacks-node / +COPY --from=build /out/stacks-inspect /out/blockstack-cli /out/clarity-cli /out/stacks-node / \ No newline at end of file diff --git a/build-scripts/Dockerfile.linux-musl-arm64 b/build-scripts/Dockerfile.linux-musl-arm64 index 24a07f018a..43b1b8e338 100644 --- a/build-scripts/Dockerfile.linux-musl-arm64 +++ b/build-scripts/Dockerfile.linux-musl-arm64 @@ -16,7 +16,6 @@ RUN --mount=type=tmpfs,target=${BUILD_DIR} cp -R /src/. ${BUILD_DIR}/ \ && cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} --bin stacks-node --bin stacks-inspect --bin clarity-cli --bin blockstack-cli \ && mkdir -p /out \ && cp -R ${BUILD_DIR}/target/${TARGET}/release/. /out - +# --bin stacks-node --bin stacks-inspect --bin clarity-cli --bin blockstack-cli FROM scratch AS export-stage -COPY --from=build /out/stacks-inspect /out/blockstack-cli /out/clarity-cli /out/stacks-node / - +COPY --from=build /out/stacks-inspect /out/blockstack-cli /out/clarity-cli /out/stacks-node / \ No newline at end of file diff --git a/build-scripts/Dockerfile.linux-musl-armv7 b/build-scripts/Dockerfile.linux-musl-armv7 index 2ce5a99912..c7ba40b4c4 100644 --- a/build-scripts/Dockerfile.linux-musl-armv7 +++ b/build-scripts/Dockerfile.linux-musl-armv7 @@ -16,6 +16,6 @@ RUN --mount=type=tmpfs,target=${BUILD_DIR} cp -R /src/. ${BUILD_DIR}/ \ && cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} --bin stacks-node --bin stacks-inspect --bin clarity-cli --bin blockstack-cli \ && mkdir -p /out \ && cp -R ${BUILD_DIR}/target/${TARGET}/release/. /out - +# --bin stacks-node --bin stacks-inspect --bin clarity-cli --bin blockstack-cli FROM scratch AS export-stage -COPY --from=build /out/stacks-inspect /out/blockstack-cli /out/clarity-cli /out/stacks-node / +COPY --from=build /out/stacks-inspect /out/blockstack-cli /out/clarity-cli /out/stacks-node / \ No newline at end of file diff --git a/build-scripts/Dockerfile.linux-musl-x64 b/build-scripts/Dockerfile.linux-musl-x64 index d954708a0a..f1df24a537 100644 --- a/build-scripts/Dockerfile.linux-musl-x64 +++ b/build-scripts/Dockerfile.linux-musl-x64 @@ -5,20 +5,20 @@ ARG GIT_BRANCH='No Branch Info' ARG GIT_COMMIT='No Commit Info' ARG BUILD_DIR=/build ARG TARGET=x86_64-unknown-linux-musl -# Allow us to override the default `--target-cpu` for the given target triplet ARG TARGET_CPU +ENV RUSTFLAGS="${TARGET_CPU:+${RUSTFLAGS} -Ctarget-cpu=${TARGET_CPU}}" WORKDIR /src COPY . . -RUN apk update && apk add git musl-dev +RUN echo "RUSTFLAGS: ${RUSTFLAGS}" +RUN apk update && apk add git musl-dev make # Run all the build steps in ramdisk in an attempt to speed things up RUN --mount=type=tmpfs,target=${BUILD_DIR} cp -R /src/. ${BUILD_DIR}/ \ && cd ${BUILD_DIR} \ && rustup target add ${TARGET} \ - ${TARGET_CPU:+RUSTFLAGS="$RUSTFLAGS $TARGET_CPU"} \ - cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} --bin stacks-node --bin stacks-inspect --bin clarity-cli --bin blockstack-cli \ + && cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} --bin stacks-node --bin stacks-inspect --bin clarity-cli --bin blockstack-cli \ && mkdir -p /out \ && cp -R ${BUILD_DIR}/target/${TARGET}/release/. /out diff --git a/build-scripts/Dockerfile.macos-arm64 b/build-scripts/Dockerfile.macos-arm64 index 0fd8a1e4c3..8f5c92d4f8 100644 --- a/build-scripts/Dockerfile.macos-arm64 +++ b/build-scripts/Dockerfile.macos-arm64 @@ -24,7 +24,6 @@ RUN --mount=type=tmpfs,target=${BUILD_DIR} cp -R /src/. ${BUILD_DIR}/ \ && cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} --bin stacks-node --bin stacks-inspect --bin clarity-cli --bin blockstack-cli \ && mkdir -p /out \ && cp -R ${BUILD_DIR}/target/${TARGET}/release/. /out - +# --bin stacks-node --bin stacks-inspect --bin clarity-cli --bin blockstack-cli FROM scratch AS export-stage -COPY --from=build /out/stacks-inspect /out/blockstack-cli /out/clarity-cli /out/stacks-node / - +COPY --from=build /out/stacks-inspect /out/blockstack-cli /out/clarity-cli /out/stacks-node / \ No newline at end of file diff --git a/build-scripts/Dockerfile.macos-x64 b/build-scripts/Dockerfile.macos-x64 index f61d0574e9..ca14012717 100644 --- a/build-scripts/Dockerfile.macos-x64 +++ b/build-scripts/Dockerfile.macos-x64 @@ -7,6 +7,7 @@ ARG BUILD_DIR=/build ARG OSXCROSS="https://github.com/hirosystems/docker-osxcross-rust/releases/download/MacOSX12.0.sdk/osxcross-d904031_MacOSX12.0.sdk.tar.zst" ARG TARGET=x86_64-apple-darwin ARG TARGET_CPU +ENV RUSTFLAGS="${TARGET_CPU:+${RUSTFLAGS} -Ctarget-cpu=${TARGET_CPU}}" WORKDIR /src COPY . . @@ -22,11 +23,9 @@ RUN --mount=type=tmpfs,target=${BUILD_DIR} cp -R /src/. ${BUILD_DIR}/ \ && cd ${BUILD_DIR} \ && rustup target add ${TARGET} \ && . /opt/osxcross/env-macos-x86_64 \ - ${TARGET_CPU:+RUSTFLAGS="$RUSTFLAGS $TARGET_CPU"} \ - cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} --bin stacks-node --bin stacks-inspect --bin clarity-cli --bin blockstack-cli \ + && cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} --bin stacks-node --bin stacks-inspect --bin clarity-cli --bin blockstack-cli \ && mkdir -p /out \ && cp -R ${BUILD_DIR}/target/${TARGET}/release/. /out - +# --bin stacks-node --bin stacks-inspect --bin clarity-cli --bin blockstack-cli FROM scratch AS export-stage -COPY --from=build /out/stacks-inspect /out/blockstack-cli /out/clarity-cli /out/stacks-node / - +COPY --from=build /out/stacks-inspect /out/blockstack-cli /out/clarity-cli /out/stacks-node / \ No newline at end of file diff --git a/build-scripts/Dockerfile.windows-x64 b/build-scripts/Dockerfile.windows-x64 index 3265c05b5c..b7fc4c8f7b 100644 --- a/build-scripts/Dockerfile.windows-x64 +++ b/build-scripts/Dockerfile.windows-x64 @@ -6,11 +6,12 @@ ARG GIT_COMMIT='No Commit Info' ARG BUILD_DIR=/build ARG TARGET=x86_64-pc-windows-gnu ARG TARGET_CPU +ENV RUSTFLAGS="${TARGET_CPU:+${RUSTFLAGS} -Ctarget-cpu=${TARGET_CPU}}" WORKDIR /src COPY . . -RUN apt-get update && apt-get install -y git gcc-mingw-w64-x86-64 +RUN apt-get update && apt-get install -y git gcc-mingw-w64-x86-64 libclang-dev # Run all the build steps in ramdisk in an attempt to speed things up RUN --mount=type=tmpfs,target=${BUILD_DIR} cp -R /src/. ${BUILD_DIR}/ \ @@ -18,10 +19,9 @@ RUN --mount=type=tmpfs,target=${BUILD_DIR} cp -R /src/. ${BUILD_DIR}/ \ && rustup target add ${TARGET} \ && CC_x86_64_pc_windows_gnu=x86_64-w64-mingw32-gcc \ CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER=x86_64-w64-mingw32-gcc \ - ${TARGET_CPU:+RUSTFLAGS="$RUSTFLAGS $TARGET_CPU"} \ cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} --bin stacks-node --bin stacks-inspect --bin clarity-cli --bin blockstack-cli \ && mkdir -p /out \ && cp -R ${BUILD_DIR}/target/${TARGET}/release/. /out - +# --bin stacks-node --bin stacks-inspect --bin clarity-cli --bin blockstack-cli FROM scratch AS export-stage -COPY --from=build /out/stacks-inspect.exe /out/blockstack-cli.exe /out/clarity-cli.exe /out/stacks-node.exe / +COPY --from=build /out/stacks-inspect.exe /out/blockstack-cli.exe /out/clarity-cli.exe /out/stacks-node.exe / \ No newline at end of file From 3a648be0739aed5e29985ddbf5fe717806bce1a1 Mon Sep 17 00:00:00 2001 From: wileyj <2847772+wileyj@users.noreply.github.com> Date: Thu, 29 Feb 2024 11:47:06 -0800 Subject: [PATCH 3/6] update workflows to support building x86-64-v3 binaries, and using glibc-x86-64-v3 arch as default for images --- .github/workflows/create-source-binary.yml | 68 +++++++++++++++++----- .github/workflows/github-release.yml | 17 ------ .github/workflows/image-build-binary.yml | 31 +++++----- .github/workflows/image-build-source.yml | 11 ++++ .github/workflows/stacks-core-tests.yml | 1 - 5 files changed, 83 insertions(+), 45 deletions(-) diff --git a/.github/workflows/create-source-binary.yml b/.github/workflows/create-source-binary.yml index 068170efc5..d0cff1cde6 100644 --- a/.github/workflows/create-source-binary.yml +++ b/.github/workflows/create-source-binary.yml @@ -9,12 +9,6 @@ on: description: "Tag name of this release (x.y.z)" required: true type: string - arch: - description: "Stringified JSON object listing of platform matrix" - required: false - type: string - default: >- - ["linux-glibc-arm64", "linux-glibc-armv7", "linux-musl-arm64", "linux-musl-armv7"] ## change the display name to the tag being built run-name: ${{ inputs.tag }} @@ -30,7 +24,7 @@ jobs: ## - workflow is building default branch (master) artifact: if: | - inputs.tag != '' && + inputs.tag != '' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) name: Build Binaries runs-on: ubuntu-latest @@ -38,33 +32,79 @@ jobs: ## Run a maximum of 10 builds concurrently, using the matrix defined in inputs.arch max-parallel: 10 matrix: - platform: ${{ fromJson(inputs.arch) }} + arch: + - linux-musl + - linux-glibc + - macos + - windows + cpu: + - arm64 + - armv7 + - x86-64 + - x86-64-v3 + exclude: + - arch: windows # excludes windows-arm64 + cpu: arm64 + - arch: windows # excludes windows-armv7 + cpu: armv7 + - arch: macos # excludes macos-armv7 + cpu: armv7 + steps: ## Setup Docker for the builds - name: Docker setup + id: docker_setup uses: stacks-network/actions/docker@main + - name: Set Local env vars + id: set_envars + run: | + case ${{ matrix.cpu }} in + x86-64) + TARGET_CPU="${{ matrix.cpu }}" + DOCKERFILE_CPU="x64" + ARCHIVE_NAME="x64" + ;; + x86-64-v3) + TARGET_CPU="${{ matrix.cpu }}" + DOCKERFILE_CPU="x64" + ARCHIVE_NAME="x64-v3" + ;; + *) + TARGET_CPU="" + DOCKERFILE_CPU="${{ matrix.cpu }}" + ARCHIVE_NAME="${{ matrix.cpu }}" + ;; + esac + echo "DOCKERFILE=Dockerfile.${{ matrix.arch }}-${DOCKERFILE_CPU}" >> "$GITHUB_ENV" + echo "ZIPFILE=${{ matrix.arch }}-${ARCHIVE_NAME}" >> "$GITHUB_ENV" + echo "TARGET_CPU=${TARGET_CPU}" >> "$GITHUB_ENV" + echo "DOCKERFILE: ${DOCKERFILE}" + echo "ZIPFILE: ${ZIPFILE}" + echo "TARGET_CPU: ${TARGET_CPU}" + ## Build the binaries using defined dockerfiles - - name: Build Binary (${{ matrix.platform }}) + - name: Build Binary (${{ matrix.arch }}_${{ matrix.cpu }}) id: build_binaries uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # 5.0.0 with: - file: build-scripts/Dockerfile.${{ matrix.platform }} - outputs: type=local,dest=./release/${{ matrix.platform }} + file: build-scripts/${{ env.DOCKERFILE }} + outputs: type=local,dest=./release/${{ matrix.arch }} build-args: | STACKS_NODE_VERSION=${{ inputs.tag || env.GITHUB_SHA_SHORT }} - OS_ARCH=${{ matrix.platform }} + OS_ARCH=${{ matrix.arch }} + TARGET_CPU=${{ env.TARGET_CPU }} GIT_BRANCH=${{ env.GITHUB_REF_SHORT }} GIT_COMMIT=${{ env.GITHUB_SHA_SHORT }} ## Compress the binary artifact - name: Compress artifact id: compress_artifact - run: zip --junk-paths ${{ matrix.platform }} ./release/${{ matrix.platform }}/* + run: zip --junk-paths ${{ env.ZIPFILE }} ./release/${{ matrix.arch }}/* ## Upload the binary artifact to the github action (used in `github-release.yml` to create a release) - name: Upload artifact id: upload_artifact uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 with: - path: ${{ matrix.platform }}.zip + path: ${{ env.ZIPFILE }}.zip diff --git a/.github/workflows/github-release.yml b/.github/workflows/github-release.yml index 17d75b2d0e..14e7117a95 100644 --- a/.github/workflows/github-release.yml +++ b/.github/workflows/github-release.yml @@ -36,21 +36,6 @@ jobs: tag: ${{ inputs.tag }} secrets: inherit - ## Build x86_64 binaries from source - ## - ## Runs when the following is true: - ## - tag is provided - ## - workflow is building default branch (master) - build-binaries-x64: - if: | - inputs.tag != '' && - github.ref == format('refs/heads/{0}', github.event.repository.default_branch) - name: Build Binaries (x64_64) - uses: ./.github/workflows/create-source-binary-x64.yml - with: - tag: ${{ inputs.tag }} - secrets: inherit - ## Runs when the following is true: ## - tag is provided ## - workflow is building default branch (master) @@ -62,7 +47,6 @@ jobs: runs-on: ubuntu-latest needs: - build-binaries - - build-binaries-x64 steps: ## Downloads the artifacts built in `create-source-binary.yml` - name: Download Artifacts @@ -111,7 +95,6 @@ jobs: uses: ./.github/workflows/image-build-binary.yml needs: - build-binaries - - build-binaries-x64 - create-release with: tag: ${{ inputs.tag }} diff --git a/.github/workflows/image-build-binary.yml b/.github/workflows/image-build-binary.yml index cab5ff162b..11a1012188 100644 --- a/.github/workflows/image-build-binary.yml +++ b/.github/workflows/image-build-binary.yml @@ -8,12 +8,7 @@ on: tag: required: true type: string - description: "Version tag for alpine images" - docker-org: - required: false - type: string - description: "Docker repo org for uploading images (defaults to github org)" - default: "${GITHUB_REPOSITORY_OWNER}" + description: "Version tag for docker images" ## Define which docker arch to build for env: @@ -48,14 +43,24 @@ jobs: steps: ## Setup Docker for the builds - name: Docker setup + id: docker_setup uses: stacks-network/actions/docker@main with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} + ## if the repo owner is not `stacks-network`, default to a docker-org of the repo owner (i.e. github user id) + ## this allows forks to run the docker push workflows without having to hardcode a dockerhub org (but it does require docker hub user to match github username) + - name: Set Local env vars + id: set_envars + if: | + github.repository_owner != 'stacks-network' + run: | + echo "docker-org=${{ github.repository_owner }}" >> "$GITHUB_ENV" + ## Set docker metatdata ## - depending on the matrix.dist, different tags will be enabled - ## ex. alpine will have this tag: `type=ref,event=tag,enable=${{ matrix.dist == 'alpine' }}` + ## ex. debian will have this tag: `type=ref,event=tag,enable=${{ matrix.dist == 'debian' }}` - name: Docker Metadata ( ${{matrix.dist}} ) id: docker_metadata uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 #v5.0.0 @@ -64,12 +69,12 @@ jobs: ${{env.docker-org}}/${{ github.event.repository.name }} ${{env.docker-org}}/stacks-blockchain tags: | - type=raw,value=latest,enable=${{ inputs.tag != '' && (github.ref == format('refs/heads/{0}', github.event.repository.default_branch) ) && matrix.dist == 'alpine' }} - type=raw,value=${{ inputs.tag }}-${{ matrix.dist }},enable=${{ inputs.tag != '' && matrix.dist == 'alpine'}} - type=raw,value=${{ inputs.tag }},enable=${{ inputs.tag != '' && matrix.dist == 'alpine' }} - type=ref,event=tag,enable=${{ matrix.dist == 'alpine' }} - type=raw,value=latest-${{ matrix.dist }},enable=${{ inputs.tag != '' && (github.ref == format('refs/heads/{0}', github.event.repository.default_branch) ) && matrix.dist == 'debian' }} - type=raw,value=${{ inputs.tag }}-${{ matrix.dist }},enable=${{ inputs.tag != '' && matrix.dist == 'debian' }} + type=raw,value=latest,enable=${{ inputs.tag != '' && (github.ref == format('refs/heads/{0}', github.event.repository.default_branch) ) && matrix.dist == 'debian' }} + type=raw,value=${{ inputs.tag }}-${{ matrix.dist }},enable=${{ inputs.tag != '' && matrix.dist == 'debian'}} + type=raw,value=${{ inputs.tag }},enable=${{ inputs.tag != '' && matrix.dist == 'debian' }} + type=ref,event=tag,enable=${{ matrix.dist == 'debian' }} + type=raw,value=latest-${{ matrix.dist }},enable=${{ inputs.tag != '' && (github.ref == format('refs/heads/{0}', github.event.repository.default_branch) ) && matrix.dist == 'alpine' }} + type=raw,value=${{ inputs.tag }}-${{ matrix.dist }},enable=${{ inputs.tag != '' && matrix.dist == 'alpine' }} ## Build docker image for release - name: Build and Push ( ${{matrix.dist}} ) diff --git a/.github/workflows/image-build-source.yml b/.github/workflows/image-build-source.yml index 1936999b27..c2609caf37 100644 --- a/.github/workflows/image-build-source.yml +++ b/.github/workflows/image-build-source.yml @@ -31,11 +31,21 @@ jobs: steps: ## Setup Docker for the builds - name: Docker setup + id: docker_setup uses: stacks-network/actions/docker@main with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} + ## if the repo owner is not `stacks-network`, default to a docker-org of the repo owner (i.e. github user id) + ## this allows forks to run the docker push workflows without having to hardcode a dockerhub org (but it does require docker hub user to match github username) + - name: Set Local env vars + id: set_envars + if: | + github.repository_owner != 'stacks-network' + run: | + echo "docker-org=${{ github.repository_owner }}" >> "$GITHUB_ENV" + ## Set docker metatdata - name: Docker Metadata ( ${{matrix.dist}} ) id: docker_metadata @@ -62,4 +72,5 @@ jobs: STACKS_NODE_VERSION=${{ env.GITHUB_SHA_SHORT }} GIT_BRANCH=${{ env.GITHUB_REF_SHORT }} GIT_COMMIT=${{ env.GITHUB_SHA_SHORT }} + TARGET_CPU=x86-64-v3 push: ${{ env.DOCKER_PUSH }} diff --git a/.github/workflows/stacks-core-tests.yml b/.github/workflows/stacks-core-tests.yml index 1e883d3d96..7e16bd5b22 100644 --- a/.github/workflows/stacks-core-tests.yml +++ b/.github/workflows/stacks-core-tests.yml @@ -166,7 +166,6 @@ jobs: # Core contract tests on Clarinet v1 # Check for false positives/negatives - # https://github.com/stacks-network/stacks-blockchain/pull/4031#pullrequestreview-1713341208 core-contracts-clarinet-test-clarinet-v1: name: Core Contracts Test Clarinet V1 runs-on: ubuntu-latest From 886b426414f40d04d7434a0a48810614542cc2a3 Mon Sep 17 00:00:00 2001 From: wileyj <2847772+wileyj@users.noreply.github.com> Date: Thu, 29 Feb 2024 11:47:57 -0800 Subject: [PATCH 4/6] cleanup, add target-cpu arg for source builds --- .github/actions/dockerfiles/Dockerfile.alpine-binary | 5 ++--- .github/actions/dockerfiles/Dockerfile.debian-binary | 9 ++++----- .github/actions/dockerfiles/Dockerfile.debian-source | 3 +++ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/actions/dockerfiles/Dockerfile.alpine-binary b/.github/actions/dockerfiles/Dockerfile.alpine-binary index 2388ffa031..61151f0d2a 100644 --- a/.github/actions/dockerfiles/Dockerfile.alpine-binary +++ b/.github/actions/dockerfiles/Dockerfile.alpine-binary @@ -10,13 +10,12 @@ ARG TARGETVARIANT ARG REPO=stacks-network/stacks-core RUN case ${TARGETARCH} in \ - "amd64") BIN_ARCH=linux-musl-x64 ;; \ + "amd64") BIN_ARCH=linux-musl-x64-v3 ;; \ "arm64") BIN_ARCH=linux-musl-arm64 ;; \ "arm") BIN_ARCH=linux-musl-armv7 ;; \ "*") exit 1 ;; \ esac \ - && echo "wget -q https://github.com/${REPO}/releases/download/${TAG}/${BIN_ARCH}.zip -O /${BIN_ARCH}.zip" \ - && wget -q https://github.com/${REPO}/releases/download/${TAG}/${BIN_ARCH}.zip -O /${BIN_ARCH}.zip \ + && wget -q https://github.com/${REPO}/releases/download/${TAG}/${BIN_ARCH}.zip -O /${BIN_ARCH}.zip \ && unzip ${BIN_ARCH}.zip -d /out FROM --platform=${TARGETPLATFORM} alpine diff --git a/.github/actions/dockerfiles/Dockerfile.debian-binary b/.github/actions/dockerfiles/Dockerfile.debian-binary index 4cec3c4391..7bfd252c04 100644 --- a/.github/actions/dockerfiles/Dockerfile.debian-binary +++ b/.github/actions/dockerfiles/Dockerfile.debian-binary @@ -10,13 +10,12 @@ ARG TARGETVARIANT ARG REPO=stacks-network/stacks-core RUN case ${TARGETARCH} in \ - "amd64") BIN_ARCH=linux-musl-x64 ;; \ - "arm64") BIN_ARCH=linux-musl-arm64 ;; \ - "arm") BIN_ARCH=linux-musl-armv7 ;; \ + "amd64") BIN_ARCH=linux-glibc-x64-v3 ;; \ + "arm64") BIN_ARCH=linux-glibc-arm64 ;; \ + "arm") BIN_ARCH=linux-glibc-armv7 ;; \ "*") exit 1 ;; \ esac \ - && echo "wget -q https://github.com/${REPO}/releases/download/${TAG}/${BIN_ARCH}.zip -O /${BIN_ARCH}.zip" \ - && wget -q https://github.com/${REPO}/releases/download/${TAG}/${BIN_ARCH}.zip -O /${BIN_ARCH}.zip \ + && wget -q https://github.com/${REPO}/releases/download/${TAG}/${BIN_ARCH}.zip -O /${BIN_ARCH}.zip \ && unzip ${BIN_ARCH}.zip -d /out FROM --platform=${TARGETPLATFORM} debian:bookworm diff --git a/.github/actions/dockerfiles/Dockerfile.debian-source b/.github/actions/dockerfiles/Dockerfile.debian-source index cbdcb9dcda..34ab555018 100644 --- a/.github/actions/dockerfiles/Dockerfile.debian-source +++ b/.github/actions/dockerfiles/Dockerfile.debian-source @@ -5,6 +5,9 @@ ARG GIT_BRANCH='No Branch Info' ARG GIT_COMMIT='No Commit Info' ARG BUILD_DIR=/build ARG TARGET=x86_64-unknown-linux-gnu +# Allow us to override the default `--target-cpu` for the given target triplet +ARG TARGET_CPU +ENV RUSTFLAGS="${TARGET_CPU:+${RUSTFLAGS} -Ctarget-cpu=${TARGET_CPU}}" WORKDIR /src COPY . . From 1999ab5f447242fb17fe3bc4560ec8b6714ecb01 Mon Sep 17 00:00:00 2001 From: wileyj <2847772+wileyj@users.noreply.github.com> Date: Fri, 1 Mar 2024 17:01:51 -0800 Subject: [PATCH 5/6] remove comments, switch to bookworm images --- .github/actions/dockerfiles/Dockerfile.debian-source | 2 +- Dockerfile.debian | 5 ++--- build-scripts/Dockerfile.linux-glibc-arm64 | 5 ++--- build-scripts/Dockerfile.linux-glibc-armv7 | 5 ++--- build-scripts/Dockerfile.linux-glibc-x64 | 4 ++-- build-scripts/Dockerfile.linux-musl-arm64 | 4 ++-- build-scripts/Dockerfile.linux-musl-armv7 | 4 ++-- build-scripts/Dockerfile.linux-musl-x64 | 1 - build-scripts/Dockerfile.macos-arm64 | 4 ++-- build-scripts/Dockerfile.macos-x64 | 4 ++-- build-scripts/Dockerfile.windows-x64 | 6 +++--- 11 files changed, 20 insertions(+), 24 deletions(-) diff --git a/.github/actions/dockerfiles/Dockerfile.debian-source b/.github/actions/dockerfiles/Dockerfile.debian-source index 34ab555018..b8da585fe2 100644 --- a/.github/actions/dockerfiles/Dockerfile.debian-source +++ b/.github/actions/dockerfiles/Dockerfile.debian-source @@ -1,4 +1,4 @@ -FROM rust:bullseye as build +FROM rust:bookworm as build ARG STACKS_NODE_VERSION="No Version Info" ARG GIT_BRANCH='No Branch Info' diff --git a/Dockerfile.debian b/Dockerfile.debian index 4b9a56b8c5..8b6759527e 100644 --- a/Dockerfile.debian +++ b/Dockerfile.debian @@ -1,4 +1,4 @@ -FROM rust:bullseye as build +FROM rust:bookworm as build ARG STACKS_NODE_VERSION="No Version Info" ARG GIT_BRANCH='No Branch Info' @@ -14,9 +14,8 @@ RUN cd testnet/stacks-node && cargo build --features monitoring_prom,slog_json - RUN cp target/release/stacks-node /out -FROM debian:bullseye-slim +FROM debian:bookworm-slim -RUN apt update && apt install -y netcat COPY --from=build /out/ /bin/ CMD ["stacks-node", "mainnet"] diff --git a/build-scripts/Dockerfile.linux-glibc-arm64 b/build-scripts/Dockerfile.linux-glibc-arm64 index 2e0587bac6..0d13237878 100644 --- a/build-scripts/Dockerfile.linux-glibc-arm64 +++ b/build-scripts/Dockerfile.linux-glibc-arm64 @@ -1,4 +1,4 @@ -FROM rust:bullseye as build +FROM rust:bookworm as build ARG STACKS_NODE_VERSION="No Version Info" ARG GIT_BRANCH='No Branch Info' @@ -21,7 +21,6 @@ RUN --mount=type=tmpfs,target=${BUILD_DIR} cp -R /src/. ${BUILD_DIR}/ \ cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} --bin stacks-node --bin stacks-inspect --bin clarity-cli --bin blockstack-cli \ && mkdir -p /out \ && cp -R ${BUILD_DIR}/target/${TARGET}/release/. /out -# --bin stacks-node --bin stacks-inspect --bin clarity-cli --bin blockstack-cli FROM scratch AS export-stage -COPY --from=build /out/stacks-inspect /out/blockstack-cli /out/clarity-cli /out/stacks-node / \ No newline at end of file +COPY --from=build /out/stacks-inspect /out/blockstack-cli /out/clarity-cli /out/stacks-node / diff --git a/build-scripts/Dockerfile.linux-glibc-armv7 b/build-scripts/Dockerfile.linux-glibc-armv7 index c28ca7d972..8192067449 100644 --- a/build-scripts/Dockerfile.linux-glibc-armv7 +++ b/build-scripts/Dockerfile.linux-glibc-armv7 @@ -1,4 +1,4 @@ -FROM rust:bullseye as build +FROM rust:bookworm as build ARG STACKS_NODE_VERSION="No Version Info" ARG GIT_BRANCH='No Branch Info' @@ -21,7 +21,6 @@ RUN --mount=type=tmpfs,target=${BUILD_DIR} cp -R /src/. ${BUILD_DIR}/ \ cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} --bin stacks-node --bin stacks-inspect --bin clarity-cli --bin blockstack-cli \ && mkdir -p /out \ && cp -R ${BUILD_DIR}/target/${TARGET}/release/. /out -# --bin stacks-node --bin stacks-inspect --bin clarity-cli --bin blockstack-cli FROM scratch AS export-stage -COPY --from=build /out/stacks-inspect /out/blockstack-cli /out/clarity-cli /out/stacks-node / \ No newline at end of file +COPY --from=build /out/stacks-inspect /out/blockstack-cli /out/clarity-cli /out/stacks-node / diff --git a/build-scripts/Dockerfile.linux-glibc-x64 b/build-scripts/Dockerfile.linux-glibc-x64 index 19f2f89c93..60bd20d6d8 100644 --- a/build-scripts/Dockerfile.linux-glibc-x64 +++ b/build-scripts/Dockerfile.linux-glibc-x64 @@ -1,4 +1,4 @@ -FROM rust:bullseye as build +FROM rust:bookworm as build ARG STACKS_NODE_VERSION="No Version Info" ARG GIT_BRANCH='No Branch Info' @@ -23,4 +23,4 @@ RUN --mount=type=tmpfs,target=${BUILD_DIR} cp -R /src/. ${BUILD_DIR}/ \ && cp -R ${BUILD_DIR}/target/${TARGET}/release/. /out FROM scratch AS export-stage -COPY --from=build /out/stacks-inspect /out/blockstack-cli /out/clarity-cli /out/stacks-node / \ No newline at end of file +COPY --from=build /out/stacks-inspect /out/blockstack-cli /out/clarity-cli /out/stacks-node / diff --git a/build-scripts/Dockerfile.linux-musl-arm64 b/build-scripts/Dockerfile.linux-musl-arm64 index 43b1b8e338..e126a1407a 100644 --- a/build-scripts/Dockerfile.linux-musl-arm64 +++ b/build-scripts/Dockerfile.linux-musl-arm64 @@ -16,6 +16,6 @@ RUN --mount=type=tmpfs,target=${BUILD_DIR} cp -R /src/. ${BUILD_DIR}/ \ && cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} --bin stacks-node --bin stacks-inspect --bin clarity-cli --bin blockstack-cli \ && mkdir -p /out \ && cp -R ${BUILD_DIR}/target/${TARGET}/release/. /out -# --bin stacks-node --bin stacks-inspect --bin clarity-cli --bin blockstack-cli + FROM scratch AS export-stage -COPY --from=build /out/stacks-inspect /out/blockstack-cli /out/clarity-cli /out/stacks-node / \ No newline at end of file +COPY --from=build /out/stacks-inspect /out/blockstack-cli /out/clarity-cli /out/stacks-node / diff --git a/build-scripts/Dockerfile.linux-musl-armv7 b/build-scripts/Dockerfile.linux-musl-armv7 index c7ba40b4c4..2ce5a99912 100644 --- a/build-scripts/Dockerfile.linux-musl-armv7 +++ b/build-scripts/Dockerfile.linux-musl-armv7 @@ -16,6 +16,6 @@ RUN --mount=type=tmpfs,target=${BUILD_DIR} cp -R /src/. ${BUILD_DIR}/ \ && cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} --bin stacks-node --bin stacks-inspect --bin clarity-cli --bin blockstack-cli \ && mkdir -p /out \ && cp -R ${BUILD_DIR}/target/${TARGET}/release/. /out -# --bin stacks-node --bin stacks-inspect --bin clarity-cli --bin blockstack-cli + FROM scratch AS export-stage -COPY --from=build /out/stacks-inspect /out/blockstack-cli /out/clarity-cli /out/stacks-node / \ No newline at end of file +COPY --from=build /out/stacks-inspect /out/blockstack-cli /out/clarity-cli /out/stacks-node / diff --git a/build-scripts/Dockerfile.linux-musl-x64 b/build-scripts/Dockerfile.linux-musl-x64 index f1df24a537..6765c4fdb1 100644 --- a/build-scripts/Dockerfile.linux-musl-x64 +++ b/build-scripts/Dockerfile.linux-musl-x64 @@ -11,7 +11,6 @@ WORKDIR /src COPY . . -RUN echo "RUSTFLAGS: ${RUSTFLAGS}" RUN apk update && apk add git musl-dev make # Run all the build steps in ramdisk in an attempt to speed things up diff --git a/build-scripts/Dockerfile.macos-arm64 b/build-scripts/Dockerfile.macos-arm64 index 8f5c92d4f8..c754f05a08 100644 --- a/build-scripts/Dockerfile.macos-arm64 +++ b/build-scripts/Dockerfile.macos-arm64 @@ -24,6 +24,6 @@ RUN --mount=type=tmpfs,target=${BUILD_DIR} cp -R /src/. ${BUILD_DIR}/ \ && cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} --bin stacks-node --bin stacks-inspect --bin clarity-cli --bin blockstack-cli \ && mkdir -p /out \ && cp -R ${BUILD_DIR}/target/${TARGET}/release/. /out -# --bin stacks-node --bin stacks-inspect --bin clarity-cli --bin blockstack-cli + FROM scratch AS export-stage -COPY --from=build /out/stacks-inspect /out/blockstack-cli /out/clarity-cli /out/stacks-node / \ No newline at end of file +COPY --from=build /out/stacks-inspect /out/blockstack-cli /out/clarity-cli /out/stacks-node / diff --git a/build-scripts/Dockerfile.macos-x64 b/build-scripts/Dockerfile.macos-x64 index ca14012717..5a33621fa6 100644 --- a/build-scripts/Dockerfile.macos-x64 +++ b/build-scripts/Dockerfile.macos-x64 @@ -26,6 +26,6 @@ RUN --mount=type=tmpfs,target=${BUILD_DIR} cp -R /src/. ${BUILD_DIR}/ \ && cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} --bin stacks-node --bin stacks-inspect --bin clarity-cli --bin blockstack-cli \ && mkdir -p /out \ && cp -R ${BUILD_DIR}/target/${TARGET}/release/. /out -# --bin stacks-node --bin stacks-inspect --bin clarity-cli --bin blockstack-cli + FROM scratch AS export-stage -COPY --from=build /out/stacks-inspect /out/blockstack-cli /out/clarity-cli /out/stacks-node / \ No newline at end of file +COPY --from=build /out/stacks-inspect /out/blockstack-cli /out/clarity-cli /out/stacks-node / diff --git a/build-scripts/Dockerfile.windows-x64 b/build-scripts/Dockerfile.windows-x64 index b7fc4c8f7b..502add30bc 100644 --- a/build-scripts/Dockerfile.windows-x64 +++ b/build-scripts/Dockerfile.windows-x64 @@ -1,4 +1,4 @@ -FROM rust:bullseye as build +FROM rust:bookworm as build ARG STACKS_NODE_VERSION="No Version Info" ARG GIT_BRANCH='No Branch Info' @@ -22,6 +22,6 @@ RUN --mount=type=tmpfs,target=${BUILD_DIR} cp -R /src/. ${BUILD_DIR}/ \ cargo build --features monitoring_prom,slog_json --release --workspace --target ${TARGET} --bin stacks-node --bin stacks-inspect --bin clarity-cli --bin blockstack-cli \ && mkdir -p /out \ && cp -R ${BUILD_DIR}/target/${TARGET}/release/. /out -# --bin stacks-node --bin stacks-inspect --bin clarity-cli --bin blockstack-cli + FROM scratch AS export-stage -COPY --from=build /out/stacks-inspect.exe /out/blockstack-cli.exe /out/clarity-cli.exe /out/stacks-node.exe / \ No newline at end of file +COPY --from=build /out/stacks-inspect.exe /out/blockstack-cli.exe /out/clarity-cli.exe /out/stacks-node.exe / From 11dd4d14d191bf0b0547ee8d10b05968c26e6af2 Mon Sep 17 00:00:00 2001 From: wileyj <2847772+wileyj@users.noreply.github.com> Date: Tue, 5 Mar 2024 12:22:59 -0800 Subject: [PATCH 6/6] addressing PR comments/default x64 builds to variant 3 --- .../dockerfiles/Dockerfile.alpine-binary | 16 ++++++----- .../dockerfiles/Dockerfile.debian-binary | 16 ++++++----- .github/workflows/create-source-binary.yml | 27 ++++++++++++++----- .github/workflows/image-build-binary.yml | 5 ++-- .github/workflows/image-build-source.yml | 5 ++-- 5 files changed, 45 insertions(+), 24 deletions(-) diff --git a/.github/actions/dockerfiles/Dockerfile.alpine-binary b/.github/actions/dockerfiles/Dockerfile.alpine-binary index 61151f0d2a..eae3a123bf 100644 --- a/.github/actions/dockerfiles/Dockerfile.alpine-binary +++ b/.github/actions/dockerfiles/Dockerfile.alpine-binary @@ -7,14 +7,18 @@ ARG TARGETPLATFORM ARG BUILDPLATFORM ARG TARGETARCH ARG TARGETVARIANT -ARG REPO=stacks-network/stacks-core +ARG REPO -RUN case ${TARGETARCH} in \ - "amd64") BIN_ARCH=linux-musl-x64-v3 ;; \ - "arm64") BIN_ARCH=linux-musl-arm64 ;; \ - "arm") BIN_ARCH=linux-musl-armv7 ;; \ - "*") exit 1 ;; \ +RUN case ${TARGETPLATFORM} in \ + linux/amd64/v2) BIN_ARCH=linux-glibc-x64-v2 ;; \ + linux/amd64*) BIN_ARCH=linux-glibc-x64 ;; \ + linux/arm64*) BIN_ARCH=linux-glibc-arm64 ;; \ + linux/arm/v7) BIN_ARCH=linux-glibc-armv7 ;; \ + *) exit 1 ;; \ esac \ + && echo "TARGETPLATFORM: $TARGETPLATFORM" \ + && echo "BIN_ARCH: $BIN_ARCH" \ + && echo "wget -q https://github.com/${REPO}/releases/download/${TAG}/${BIN_ARCH}.zip -O /${BIN_ARCH}.zip" \ && wget -q https://github.com/${REPO}/releases/download/${TAG}/${BIN_ARCH}.zip -O /${BIN_ARCH}.zip \ && unzip ${BIN_ARCH}.zip -d /out diff --git a/.github/actions/dockerfiles/Dockerfile.debian-binary b/.github/actions/dockerfiles/Dockerfile.debian-binary index 7bfd252c04..f446190853 100644 --- a/.github/actions/dockerfiles/Dockerfile.debian-binary +++ b/.github/actions/dockerfiles/Dockerfile.debian-binary @@ -7,14 +7,18 @@ ARG TARGETPLATFORM ARG BUILDPLATFORM ARG TARGETARCH ARG TARGETVARIANT -ARG REPO=stacks-network/stacks-core +ARG REPO -RUN case ${TARGETARCH} in \ - "amd64") BIN_ARCH=linux-glibc-x64-v3 ;; \ - "arm64") BIN_ARCH=linux-glibc-arm64 ;; \ - "arm") BIN_ARCH=linux-glibc-armv7 ;; \ - "*") exit 1 ;; \ +RUN case ${TARGETPLATFORM} in \ + linux/amd64/v2) BIN_ARCH=linux-glibc-x64-v2 ;; \ + linux/amd64*) BIN_ARCH=linux-glibc-x64 ;; \ + linux/arm64*) BIN_ARCH=linux-glibc-arm64 ;; \ + linux/arm/v7) BIN_ARCH=linux-glibc-armv7 ;; \ + *) exit 1 ;; \ esac \ + && echo "TARGETPLATFORM: $TARGETPLATFORM" \ + && echo "BIN_ARCH: $BIN_ARCH" \ + && echo "wget -q https://github.com/${REPO}/releases/download/${TAG}/${BIN_ARCH}.zip -O /${BIN_ARCH}.zip" \ && wget -q https://github.com/${REPO}/releases/download/${TAG}/${BIN_ARCH}.zip -O /${BIN_ARCH}.zip \ && unzip ${BIN_ARCH}.zip -d /out diff --git a/.github/workflows/create-source-binary.yml b/.github/workflows/create-source-binary.yml index d0cff1cde6..0848cf2eb4 100644 --- a/.github/workflows/create-source-binary.yml +++ b/.github/workflows/create-source-binary.yml @@ -40,8 +40,10 @@ jobs: cpu: - arm64 - armv7 - - x86-64 - - x86-64-v3 + - x86-64 ## defaults to x86-64-v3 variant - intel haswell (2013) and newer + # - x86-64-v2 ## intel nehalem (2008) and newer + # - x86-64-v3 ## intel haswell (2013) and newer + # - x86-64-v4 ## intel skylake (2017) and newer exclude: - arch: windows # excludes windows-arm64 cpu: arm64 @@ -57,19 +59,33 @@ jobs: uses: stacks-network/actions/docker@main - name: Set Local env vars - id: set_envars + id: set_env run: | case ${{ matrix.cpu }} in x86-64) - TARGET_CPU="${{ matrix.cpu }}" + ## default x64 builds to use v3 variant. TARGET_CPU is required to build for v3 via RUSTFLAGS + TARGET_CPU="${{ matrix.cpu }}-v3" DOCKERFILE_CPU="x64" ARCHIVE_NAME="x64" ;; + x86-64-v2) + ## intel nehalem (2008) and newer + TARGET_CPU="${{ matrix.cpu }}" + DOCKERFILE_CPU="x64" + ARCHIVE_NAME="x64-v2" + ;; x86-64-v3) + ## intel haswell (2013) and newer TARGET_CPU="${{ matrix.cpu }}" DOCKERFILE_CPU="x64" ARCHIVE_NAME="x64-v3" ;; + x86-64-v4) + ## intel skylake (2017) and newer + TARGET_CPU="${{ matrix.cpu }}" + DOCKERFILE_CPU="x64" + ARCHIVE_NAME="x64-v4" + ;; *) TARGET_CPU="" DOCKERFILE_CPU="${{ matrix.cpu }}" @@ -79,9 +95,6 @@ jobs: echo "DOCKERFILE=Dockerfile.${{ matrix.arch }}-${DOCKERFILE_CPU}" >> "$GITHUB_ENV" echo "ZIPFILE=${{ matrix.arch }}-${ARCHIVE_NAME}" >> "$GITHUB_ENV" echo "TARGET_CPU=${TARGET_CPU}" >> "$GITHUB_ENV" - echo "DOCKERFILE: ${DOCKERFILE}" - echo "ZIPFILE: ${ZIPFILE}" - echo "TARGET_CPU: ${TARGET_CPU}" ## Build the binaries using defined dockerfiles - name: Build Binary (${{ matrix.arch }}_${{ matrix.cpu }}) diff --git a/.github/workflows/image-build-binary.yml b/.github/workflows/image-build-binary.yml index 11a1012188..b804ae3be6 100644 --- a/.github/workflows/image-build-binary.yml +++ b/.github/workflows/image-build-binary.yml @@ -12,7 +12,7 @@ on: ## Define which docker arch to build for env: - docker_platforms: "linux/arm64, linux/arm/v7, linux/amd64, linux/amd64/v2, linux/amd64/v3" + docker_platforms: "linux/arm64, linux/arm/v7, linux/amd64, linux/amd64/v3" docker-org: blockstack concurrency: @@ -52,7 +52,7 @@ jobs: ## if the repo owner is not `stacks-network`, default to a docker-org of the repo owner (i.e. github user id) ## this allows forks to run the docker push workflows without having to hardcode a dockerhub org (but it does require docker hub user to match github username) - name: Set Local env vars - id: set_envars + id: set_env if: | github.repository_owner != 'stacks-network' run: | @@ -65,6 +65,7 @@ jobs: id: docker_metadata uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 #v5.0.0 with: + ## tag images with current repo name `stacks-core` as well as legacy `stacks-blockchain` images: | ${{env.docker-org}}/${{ github.event.repository.name }} ${{env.docker-org}}/stacks-blockchain diff --git a/.github/workflows/image-build-source.yml b/.github/workflows/image-build-source.yml index c2609caf37..ebb9afc679 100644 --- a/.github/workflows/image-build-source.yml +++ b/.github/workflows/image-build-source.yml @@ -8,7 +8,7 @@ on: ## Define which docker arch to build for env: - docker_platforms: linux/amd64 + docker_platforms: "linux/amd64" docker-org: blockstack concurrency: @@ -40,7 +40,7 @@ jobs: ## if the repo owner is not `stacks-network`, default to a docker-org of the repo owner (i.e. github user id) ## this allows forks to run the docker push workflows without having to hardcode a dockerhub org (but it does require docker hub user to match github username) - name: Set Local env vars - id: set_envars + id: set_env if: | github.repository_owner != 'stacks-network' run: | @@ -68,7 +68,6 @@ jobs: tags: ${{ steps.docker_metadata.outputs.tags }} labels: ${{ steps.docker_metadata.outputs.labels }} build-args: | - REPO=${{ github.repository_owner }}/${{ github.event.repository.name }} STACKS_NODE_VERSION=${{ env.GITHUB_SHA_SHORT }} GIT_BRANCH=${{ env.GITHUB_REF_SHORT }} GIT_COMMIT=${{ env.GITHUB_SHA_SHORT }}