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 9ed4daf0..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') }} @@ -98,34 +91,34 @@ jobs: 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 @@ -135,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 @@ -157,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 @@ -175,7 +168,7 @@ jobs: shell: bash - name: Test Compatibility - if: ${{ !matrix.docker }} + if: ${{ !matrix.dockerfile }} uses: nick-fields/retry@v3 with: timeout_minutes: 5 @@ -189,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 @@ -199,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/README.md b/README.md index 4fa41e72..1ccdfe09 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ zmq_curve="true" zmq_sodium="true" ``` -Building libsodium requires running `brew install autoconf automake libtool` +Building libsodium requires these dependencies on Linux/MacOS: `autoconf automake libtool`, which can be installed via `apt-get` or `brew`, etc. #### Draft support 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