Skip to content

Commit 16c3a45

Browse files
committed
Try to use a Dockerfile to make the musl builds
1 parent 3c9674c commit 16c3a45

6 files changed

Lines changed: 110 additions & 214 deletions

File tree

.github/workflows/typescript-napi-ci.yaml

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ jobs:
1515
matrix:
1616
rust_version:
1717
- stable
18-
# Uncomment after Rust 1.90.0 comes out: https://github.com/rust-lang/rust/issues/145699
19-
# - beta
18+
- beta
19+
# These should match those in the `docker-test` job
2020
node_version:
2121
- 20
2222
- 22
@@ -55,33 +55,15 @@ jobs:
5555
- name: Run tests
5656
run: yarn run test
5757

58-
test-docker:
59-
runs-on: ${{ matrix.os }}
60-
container:
61-
image: node:${{ matrix.node_version }}-alpine
58+
# Used to create musl binaries
59+
docker-test:
60+
runs-on: ${{ matrix.system.os }}
6261
strategy:
6362
matrix:
64-
rust_version:
65-
- stable
66-
- beta
67-
node_version:
68-
- 20
69-
- 22
70-
- 24
71-
os:
72-
- ubuntu-24.04
73-
- ubuntu-24.04-arm
63+
system:
64+
- os: [ubuntu-24.04, ubuntu-24.04-arm]
7465
fail-fast: false
7566
steps:
76-
- run: apk add build-base git python3 wget
77-
- run: echo RUSTFLAGS="-C target-feature=-crt-static" >> "${GITHUB_ENV}"
7867
- uses: actions/checkout@v5
79-
- uses: IronCoreLabs/rust-toolchain@v1
80-
with:
81-
toolchain: ${{ matrix.rust_version }}
82-
- name: Install modules
83-
run: yarn install --ignore-scripts
84-
- name: Compile
85-
run: yarn run compile
86-
- name: Run tests
87-
run: yarn run test
68+
# These Node versions should match those above in the `test` job.
69+
- run: for NODE_VERSION in 20 22 24; do docker build --build-arg NODE_VERSION=$NODE_VERSION .; done

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ target
88
artifacts.json
99
dist/*
1010
bin-package/*
11+
host-artifacts/*
1112
build/*
1213
.idea/*
1314
.direnv

Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# This Dockerfile produces a musl binary for recrypt-node-binding.
2+
# It can be built with this command to copy the result out into ./host-artifacts/out
3+
# docker build --build-arg NODE_VERSION=24 --output type=local,dest=./host-artifacts .
4+
5+
ARG NODE_VERSION=24
6+
FROM node:${NODE_VERSION}-alpine3.22 AS build
7+
8+
RUN apk add --no-cache \
9+
build-base \
10+
rust \
11+
cargo
12+
COPY . /app
13+
WORKDIR /app
14+
RUN yarn install
15+
RUN node publish.js
16+
17+
FROM scratch AS artifacts
18+
WORKDIR /out
19+
COPY --from=build /app/bin-package ./

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"test": "jest --maxWorkers=50%"
3131
},
3232
"dependencies": {
33-
"@mapbox/node-pre-gyp": "^1.0.7"
33+
"@mapbox/node-pre-gyp": "^2.0.0"
3434
},
3535
"devDependencies": {
3636
"@types/node": "^16.11.11",

publish.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* + Compile rust code into index.node file.
1212
* + Run unit tests to ensure the library is in good shape for publishing.
1313
* + Move all expected content into a `dist` directory.
14-
* + Generate a binary distrubtion in `bin-package`.
14+
* + Generate a binary distribution in `bin-package`.
1515
* + Do a dry run of npm publishing via irish-pub or perform an actual publish step if `--publish` option is provided.
1616
*/
1717

@@ -63,7 +63,7 @@ var tgz = shell.exec("find ./build -name *.tar.gz");
6363
shell.cp(tgz, "./bin-package/");
6464
shell.pushd("./dist");
6565

66-
var publishCmd = "echo 'Skipping publishing to npm...'"
66+
var publishCmd = "echo 'Skipping publishing to npm...'";
6767
if (shouldPublish) {
6868
publishCmd = "npm publish --access public";
6969
// If we're publishing a branch build or prerelease like "1.2.3-pre.4", use "--tag next".

0 commit comments

Comments
 (0)