Skip to content

Commit 9d69b11

Browse files
authored
Merge pull request #682 from zeromq/curve
2 parents 9f1172d + bee9265 commit 9d69b11

File tree

6 files changed

+97
-54
lines changed

6 files changed

+97
-54
lines changed

.dockerignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
docker/*.dockerfile
2+
.dockerignore
3+
.git/
4+
build
5+
docs
6+
lib
7+
tmp
8+
**/node_modules
9+
**/yarn.lock
10+
**/yarn-error.log
11+
**/package-lock.json
12+
**/lib/binary/*.node
13+
**/lib/binary/napi-v*/*.node
14+
**/build-tmp-napi-v*
15+
prebuilds
16+
**/test.js
17+
**/.cache/
18+
**/test/typings-compatibility/
19+
script/*.d.ts
20+
script/*.d.*ts
21+
script/*js.map
22+
**/tsconfig.tsbuildinfo
23+
**/tsconfig.*.tsbuildinfo
24+
doc-unminified
25+
**/.DS_Store
26+
**/.idea
27+
staging
28+
!lib/load-addon.js
29+
!lib/load-addon.js.map
30+
31+
**/compile_commands.json
32+
33+
smoke-test-*
34+
*.tgz
35+

.github/workflows/CI.yml

Lines changed: 23 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ jobs:
1919
- x64
2020
cpp_arch:
2121
- x64
22-
docker:
23-
- ""
24-
docker_cmd:
22+
dockerfile:
2523
- ""
2624

2725
include:
@@ -44,12 +42,7 @@ jobs:
4442

4543
# Alpine
4644
- os: ubuntu-22.04
47-
docker: node:18-alpine
48-
docker_cmd:
49-
apk add --no-cache bash build-base curl git g++ make ninja-build
50-
pkgconfig unzip zip python3 tar cmake ninja musl-dev && cp
51-
/usr/lib/ninja-build/bin/ninja /usr/bin/ninja && npm i -g pnpm &&
52-
pnpm install && pnpm run build
45+
dockerfile: docker/alpine.dockerfile
5346
node_arch: x64
5447
cpp_arch: x64
5548

@@ -82,7 +75,7 @@ jobs:
8275
shell: bash
8376

8477
- name: Setup Cpp
85-
if: ${{ !matrix.docker }}
78+
if: ${{ !matrix.dockerfile }}
8679
uses: aminya/setup-cpp@v1
8780
with:
8881
vcvarsall: ${{ contains(matrix.os, 'windows') }}
@@ -92,48 +85,40 @@ jobs:
9285
vcpkg: true
9386
architecture: ${{ matrix.cpp_arch }}
9487

95-
- name: Install Mac-OS x86_64 Dependencies
96-
if: ${{ contains(matrix.os, 'macos') && matrix.node_arch == 'x64' }}
97-
run: |
98-
brew install libsodium gnutls
99-
100-
- name: Install Mac-OS arm64 Dependencies
101-
if: ${{ contains(matrix.os, 'macos') && matrix.node_arch == 'arm64' }}
88+
- name: Install Mac-OS Dependencies
89+
if: ${{ contains(matrix.os, 'macos') }}
10290
run: |
103-
brew uninstall libsodium --force --ignore-dependencies
104-
source ./script/macos-arm-deps.sh
105-
echo "PATH=$PATH" >> $GITHUB_ENV
106-
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> $GITHUB_ENV
91+
brew install gnutls autoconf automake libtool
10792
10893
- uses: pnpm/action-setup@v4
109-
if: ${{ !matrix.docker }}
94+
if: ${{ !matrix.dockerfile }}
11095
with:
11196
version: 9
11297

11398
- name: Install Node 20
114-
if: ${{ !matrix.docker }}
99+
if: ${{ !matrix.dockerfile }}
115100
uses: actions/setup-node@v4
116101
with:
117102
node-version: 20
118103
architecture: ${{ env.setup_node_arch }}
119104

120105
- name: Install and Build Native
121-
if: ${{ !matrix.docker }}
106+
if: ${{ !matrix.dockerfile }}
122107
run: pnpm install
123108

124109
- name: Build JavaScript
125-
if: ${{ !matrix.docker }}
110+
if: ${{ !matrix.dockerfile }}
126111
run: pnpm run build.js
127112

128113
- name: Install Node 10
129-
if: ${{ !matrix.docker && matrix.os != 'macos-14' }}
114+
if: ${{ !matrix.dockerfile && matrix.os != 'macos-14' }}
130115
uses: actions/setup-node@v4
131116
with:
132117
node-version: 10
133118
architecture: ${{ env.setup_node_arch }}
134119

135120
- name: Build Native
136-
if: ${{ !matrix.docker && matrix.node_arch != 'ia32' }}
121+
if: ${{ !matrix.dockerfile && matrix.node_arch != 'ia32' }}
137122
run: npm run build.native
138123

139124
- name: Build Native Windows 32
@@ -143,19 +128,19 @@ jobs:
143128
windows-x86
144129

145130
- name: Use Node 20
146-
if: ${{ !matrix.docker }}
131+
if: ${{ !matrix.dockerfile }}
147132
uses: actions/setup-node@v4
148133
with:
149134
node-version: 20
150135
architecture: ${{ env.setup_node_arch }}
151136

152137
- name: Prebuild Docker
153-
if: ${{ matrix.docker }}
138+
if: ${{ matrix.dockerfile }}
154139
run: |
155-
docker login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io
156-
docker pull ${{ matrix.docker }}
157-
docker tag ${{ matrix.docker }} builder
158-
docker run --volume ${{ github.workspace }}:/app --workdir /app --privileged builder sh -c "${{ matrix.docker_cmd }}"
140+
docker build -t zeromq -f ${{ matrix.dockerfile }} .
141+
docker create --name zeromq-temp zeromq
142+
docker cp zeromq-temp:/app/build ./build
143+
docker rm -f zeromq-temp
159144
160145
- name: Upload build
161146
uses: actions/upload-artifact@v4
@@ -165,11 +150,11 @@ jobs:
165150
overwrite: true
166151

167152
- name: Lint
168-
if: "${{ contains(matrix.os, 'ubuntu') && !matrix.docker }}"
153+
if: "${{ contains(matrix.os, 'ubuntu') && !matrix.dockerfile }}"
169154
run: pnpm run lint-test
170155

171156
- name: Test
172-
if: ${{ !matrix.docker }}
157+
if: ${{ !matrix.dockerfile }}
173158
uses: nick-fields/retry@v3
174159
with:
175160
timeout_minutes: 5
@@ -183,7 +168,7 @@ jobs:
183168
shell: bash
184169

185170
- name: Test Compatibility
186-
if: ${{ !matrix.docker }}
171+
if: ${{ !matrix.dockerfile }}
187172
uses: nick-fields/retry@v3
188173
with:
189174
timeout_minutes: 5
@@ -197,7 +182,7 @@ jobs:
197182
shell: bash
198183

199184
- name: Test Electron Windows/MacOS
200-
if: "${{ !matrix.docker }}"
185+
if: "${{ !matrix.dockerfile }}"
201186
uses: nick-fields/retry@v3
202187
with:
203188
timeout_minutes: 5
@@ -207,7 +192,7 @@ jobs:
207192
continue-on-error: true
208193

209194
- name: Test Electron Linux
210-
if: "${{ contains(matrix.os, 'ubuntu') && !matrix.docker }}"
195+
if: "${{ contains(matrix.os, 'ubuntu') && !matrix.dockerfile }}"
211196
uses: nick-fields/retry@v3
212197
with:
213198
timeout_minutes: 5

CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,16 @@ endmacro()
3131
option(ZMQ_DRAFT "Build and install draft APIs" OFF)
3232
set_option_from_env(ZMQ_DRAFT)
3333

34-
option(ZMQ_CURVE "Enable CURVE security" OFF)
34+
option(ZMQ_CURVE "Enable CURVE security" ON)
3535
set_option_from_env(ZMQ_CURVE)
3636

37-
option(ZMQ_SODIUM "Using libsodium for CURVE security" OFF)
37+
option(ZMQ_SODIUM "Using libsodium for CURVE security" ON)
3838
set_option_from_env(ZMQ_SODIUM)
3939

40+
if(ZMQ_SODIUM AND APPLE)
41+
message(STATUS "building libsodium requires running `brew install autoconf automake libtool`")
42+
endif()
43+
4044
option(ZMQ_WEBSOCKETS "Enable WebSocket transport" OFF)
4145
set_option_from_env(ZMQ_WEBSOCKETS)
4246

README.md

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
- [Prebuilt binaries](#prebuilt-binaries)
3030
- [Building from source](#building-from-source)
3131
- [Available Build Options](#available-build-options)
32-
- [Curve support](#curve-support)
33-
- [Libsodium for Curve](#libsodium-for-curve)
32+
- [Curve with Libsodium support](#curve-with-libsodium-support)
3433
- [Draft support](#draft-support)
3534
- [Websocket support](#websocket-support)
3635
- [Secure Websocket support](#secure-websocket-support)
@@ -117,25 +116,17 @@ When building from source, you can also specify additional build options in a
117116
<details>
118117
<summary>👉🏻 Options</summary>
119118

120-
### Curve support
119+
### Curve with Libsodium support
121120

122-
Enables CURVE security for encrypted communications. To enable CURVE support,
123-
add the following to your .npmrc:
121+
Enables CURVE security for encrypted communications. Zeromq uses libsodium for CURVE security. To enable CURVE support, add the following to your .npmrc:
124122

125123
```ini
126124
zmq_curve="true"
127-
```
128-
129-
### Libsodium for Curve
130-
131-
Enable libsodium for CURVE security instead of the built-in tweetnacl
132-
implementation. This can provide better performance for CURVE operations. To use
133-
libsodium, add the following to your .npmrc:
134-
135-
```ini
136125
zmq_sodium="true"
137126
```
138127

128+
Building libsodium requires these dependencies on Linux/MacOS: `autoconf automake libtool`, which can be installed via `apt-get` or `brew`, etc.
129+
139130
#### Draft support
140131

141132
By default `libzmq` is built with support for `Draft` patterns (e.g.

docker/alpine.dockerfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
FROM node:18-alpine
2+
3+
WORKDIR /app
4+
COPY ./ ./
5+
ENV VCPKG_FORCE_SYSTEM_BINARIES=1
6+
RUN apk add --no-cache \
7+
bash \
8+
build-base \
9+
curl \
10+
git \
11+
g++ \
12+
make \
13+
ninja-build \
14+
pkgconfig \
15+
unzip \
16+
zip \
17+
python3 \
18+
tar \
19+
cmake \
20+
ninja \
21+
musl-dev \
22+
automake \
23+
autoconf \
24+
libtool && \
25+
cp /usr/lib/ninja-build/bin/ninja /usr/bin/ninja && \
26+
npm i -g pnpm && \
27+
pnpm install && \
28+
pnpm run build
File renamed without changes.

0 commit comments

Comments
 (0)