diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..4afbb2e9 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,35 @@ +docker/*.dockerfile +.dockerignore +.git/ +build +docs +lib +tmp +**/node_modules +**/yarn.lock +**/yarn-error.log +**/package-lock.json +**/lib/binary/*.node +**/lib/binary/napi-v*/*.node +**/build-tmp-napi-v* +prebuilds +**/test.js +**/.cache/ +**/test/typings-compatibility/ +script/*.d.ts +script/*.d.*ts +script/*js.map +**/tsconfig.tsbuildinfo +**/tsconfig.*.tsbuildinfo +doc-unminified +**/.DS_Store +**/.idea +staging +!lib/load-addon.js +!lib/load-addon.js.map + +**/compile_commands.json + +smoke-test-* +*.tgz + diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index da8c0526..1ae54bb1 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -19,9 +19,7 @@ jobs: - x64 cpp_arch: - x64 - docker: - - "" - docker_cmd: + dockerfile: - "" include: @@ -44,12 +42,7 @@ jobs: # Alpine - os: ubuntu-22.04 - docker: node:18-alpine - docker_cmd: - apk add --no-cache bash build-base curl git g++ make ninja-build - pkgconfig unzip zip python3 tar cmake ninja musl-dev && cp - /usr/lib/ninja-build/bin/ninja /usr/bin/ninja && npm i -g pnpm && - pnpm install && pnpm run build + dockerfile: docker/alpine.dockerfile node_arch: x64 cpp_arch: x64 @@ -82,7 +75,7 @@ jobs: shell: bash - name: Setup Cpp - if: ${{ !matrix.docker }} + if: ${{ !matrix.dockerfile }} uses: aminya/setup-cpp@v1 with: vcvarsall: ${{ contains(matrix.os, 'windows') }} @@ -92,48 +85,40 @@ jobs: vcpkg: true architecture: ${{ matrix.cpp_arch }} - - name: Install Mac-OS x86_64 Dependencies - if: ${{ contains(matrix.os, 'macos') && matrix.node_arch == 'x64' }} - run: | - brew install libsodium gnutls - - - name: Install Mac-OS arm64 Dependencies - if: ${{ contains(matrix.os, 'macos') && matrix.node_arch == 'arm64' }} + - name: Install Mac-OS Dependencies + if: ${{ contains(matrix.os, 'macos') }} run: | - brew uninstall libsodium --force --ignore-dependencies - source ./script/macos-arm-deps.sh - echo "PATH=$PATH" >> $GITHUB_ENV - echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> $GITHUB_ENV + brew install gnutls autoconf automake libtool - uses: pnpm/action-setup@v4 - if: ${{ !matrix.docker }} + if: ${{ !matrix.dockerfile }} with: version: 9 - name: Install Node 20 - if: ${{ !matrix.docker }} + if: ${{ !matrix.dockerfile }} uses: actions/setup-node@v4 with: node-version: 20 architecture: ${{ env.setup_node_arch }} - name: Install and Build Native - if: ${{ !matrix.docker }} + if: ${{ !matrix.dockerfile }} run: pnpm install - name: Build JavaScript - if: ${{ !matrix.docker }} + if: ${{ !matrix.dockerfile }} run: pnpm run build.js - name: Install Node 10 - if: ${{ !matrix.docker && matrix.os != 'macos-14' }} + if: ${{ !matrix.dockerfile && matrix.os != 'macos-14' }} uses: actions/setup-node@v4 with: node-version: 10 architecture: ${{ env.setup_node_arch }} - name: Build Native - if: ${{ !matrix.docker && matrix.node_arch != 'ia32' }} + if: ${{ !matrix.dockerfile && matrix.node_arch != 'ia32' }} run: npm run build.native - name: Build Native Windows 32 @@ -143,19 +128,19 @@ jobs: windows-x86 - name: Use Node 20 - if: ${{ !matrix.docker }} + if: ${{ !matrix.dockerfile }} uses: actions/setup-node@v4 with: node-version: 20 architecture: ${{ env.setup_node_arch }} - name: Prebuild Docker - if: ${{ matrix.docker }} + if: ${{ matrix.dockerfile }} run: | - docker login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io - docker pull ${{ matrix.docker }} - docker tag ${{ matrix.docker }} builder - docker run --volume ${{ github.workspace }}:/app --workdir /app --privileged builder sh -c "${{ matrix.docker_cmd }}" + docker build -t zeromq -f ${{ matrix.dockerfile }} . + docker create --name zeromq-temp zeromq + docker cp zeromq-temp:/app/build ./build + docker rm -f zeromq-temp - name: Upload build uses: actions/upload-artifact@v4 @@ -165,11 +150,11 @@ jobs: overwrite: true - name: Lint - if: "${{ contains(matrix.os, 'ubuntu') && !matrix.docker }}" + if: "${{ contains(matrix.os, 'ubuntu') && !matrix.dockerfile }}" run: pnpm run lint-test - name: Test - if: ${{ !matrix.docker }} + if: ${{ !matrix.dockerfile }} uses: nick-fields/retry@v3 with: timeout_minutes: 5 @@ -183,7 +168,7 @@ jobs: shell: bash - name: Test Compatibility - if: ${{ !matrix.docker }} + if: ${{ !matrix.dockerfile }} uses: nick-fields/retry@v3 with: timeout_minutes: 5 @@ -197,7 +182,7 @@ jobs: shell: bash - name: Test Electron Windows/MacOS - if: "${{ !matrix.docker }}" + if: "${{ !matrix.dockerfile }}" uses: nick-fields/retry@v3 with: timeout_minutes: 5 @@ -207,7 +192,7 @@ jobs: continue-on-error: true - name: Test Electron Linux - if: "${{ contains(matrix.os, 'ubuntu') && !matrix.docker }}" + if: "${{ contains(matrix.os, 'ubuntu') && !matrix.dockerfile }}" uses: nick-fields/retry@v3 with: timeout_minutes: 5 diff --git a/CMakeLists.txt b/CMakeLists.txt index 91c94d73..96334054 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,12 +31,16 @@ endmacro() option(ZMQ_DRAFT "Build and install draft APIs" OFF) set_option_from_env(ZMQ_DRAFT) -option(ZMQ_CURVE "Enable CURVE security" OFF) +option(ZMQ_CURVE "Enable CURVE security" ON) set_option_from_env(ZMQ_CURVE) -option(ZMQ_SODIUM "Using libsodium for CURVE security" OFF) +option(ZMQ_SODIUM "Using libsodium for CURVE security" ON) set_option_from_env(ZMQ_SODIUM) +if(ZMQ_SODIUM AND APPLE) + message(STATUS "building libsodium requires running `brew install autoconf automake libtool`") +endif() + option(ZMQ_WEBSOCKETS "Enable WebSocket transport" OFF) set_option_from_env(ZMQ_WEBSOCKETS) diff --git a/README.md b/README.md index 1b0f19f1..1ccdfe09 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,7 @@ - [Prebuilt binaries](#prebuilt-binaries) - [Building from source](#building-from-source) - [Available Build Options](#available-build-options) - - [Curve support](#curve-support) - - [Libsodium for Curve](#libsodium-for-curve) + - [Curve with Libsodium support](#curve-with-libsodium-support) - [Draft support](#draft-support) - [Websocket support](#websocket-support) - [Secure Websocket support](#secure-websocket-support) @@ -117,25 +116,17 @@ When building from source, you can also specify additional build options in a
👉🏻 Options -### Curve support +### Curve with Libsodium support -Enables CURVE security for encrypted communications. To enable CURVE support, -add the following to your .npmrc: +Enables CURVE security for encrypted communications. Zeromq uses libsodium for CURVE security. To enable CURVE support, add the following to your .npmrc: ```ini zmq_curve="true" -``` - -### Libsodium for Curve - -Enable libsodium for CURVE security instead of the built-in tweetnacl -implementation. This can provide better performance for CURVE operations. To use -libsodium, add the following to your .npmrc: - -```ini zmq_sodium="true" ``` +Building libsodium requires these dependencies on Linux/MacOS: `autoconf automake libtool`, which can be installed via `apt-get` or `brew`, etc. + #### Draft support By default `libzmq` is built with support for `Draft` patterns (e.g. diff --git a/docker/alpine.dockerfile b/docker/alpine.dockerfile new file mode 100644 index 00000000..21a99e5c --- /dev/null +++ b/docker/alpine.dockerfile @@ -0,0 +1,28 @@ +FROM node:18-alpine + +WORKDIR /app +COPY ./ ./ +ENV VCPKG_FORCE_SYSTEM_BINARIES=1 +RUN apk add --no-cache \ + bash \ + build-base \ + curl \ + git \ + g++ \ + make \ + ninja-build \ + pkgconfig \ + unzip \ + zip \ + python3 \ + tar \ + cmake \ + ninja \ + musl-dev \ + automake \ + autoconf \ + libtool && \ + cp /usr/lib/ninja-build/bin/ninja /usr/bin/ninja && \ + npm i -g pnpm && \ + pnpm install && \ + pnpm run build diff --git a/script/macos-arm-deps.sh b/script/macos-cross-arm-deps.sh similarity index 100% rename from script/macos-arm-deps.sh rename to script/macos-cross-arm-deps.sh