Skip to content

Commit

Permalink
ci: add dockerfile for building on Alpine Musl
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Dec 29, 2024
1 parent 2402a5d commit bee9265
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 28 deletions.
35 changes: 35 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -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

47 changes: 20 additions & 27 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ jobs:
- x64
cpp_arch:
- x64
docker:
- ""
docker_cmd:
dockerfile:
- ""

include:
Expand All @@ -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

Expand Down Expand Up @@ -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') }}
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
28 changes: 28 additions & 0 deletions docker/alpine.dockerfile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit bee9265

Please sign in to comment.