Skip to content

Commit a0e4f0b

Browse files
Merge pull request #10 from Asana/node20.18.3_dockerfile
Node20.18.3 dockerfile
2 parents 2e3111e + 7522419 commit a0e4f0b

7 files changed

Lines changed: 362 additions & 1 deletion

File tree

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Build node-fibers with prebuilt Node
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- node20.18.3_dockerfile
8+
9+
jobs:
10+
build-fibers:
11+
strategy:
12+
matrix:
13+
include:
14+
- platform: linux
15+
arch: x64
16+
runs_on: ubuntu-22.04
17+
- platform: linux
18+
arch: arm64
19+
runs_on: ubuntu-22.04-arm
20+
runs-on: ${{ matrix.runs_on }}
21+
22+
env:
23+
NODE_VERSION: v20.18.3
24+
25+
steps:
26+
- name: Debug Matrix Values
27+
run: |
28+
echo "Matrix platform: ${{ matrix.platform }}"
29+
echo "Matrix arch: ${{ matrix.arch }}"
30+
31+
- name: Download Node archive
32+
run: |
33+
gh release download node-${{ env.NODE_VERSION }}-release \
34+
--repo asana/node \
35+
--pattern "node-${{ env.NODE_VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}-LATEST.tar.xz"
36+
mv node-${{ env.NODE_VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}-LATEST.tar.xz node.tar.xz
37+
pwd
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
41+
- name: Download Dockerfile from GitHub API
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
run: |
45+
curl -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3.raw" -o Dockerfile.Fibers https://api.github.com/repos/Asana/node/contents/Dockerfile.Fibers?ref=node20.18.3_dockerfile
46+
cat Dockerfile.Fibers
47+
pwd
48+
49+
- name: Execute the Dockerfile
50+
run: |
51+
pwd
52+
docker build -t node20_fibers_build -f Dockerfile.Fibers .
53+
54+
- name: Extract resources
55+
run: |
56+
docker create --name temp_node_fibers_extract node20_fibers_build
57+
docker cp temp_node_fibers_extract:/usr/src/node/node-fibers $GITHUB_WORKSPACE/node-fibers
58+
docker rm temp_node_fibers_extract
59+
60+
- name: Find and archive fibers.node
61+
run: |
62+
# Find the directory under bin/ that contains fibers.node
63+
FIBERS_PATH=$(find ./node-fibers/bin -type f -name fibers.node | head -n1)
64+
FIBERS_DIR=$(dirname "$FIBERS_PATH")
65+
ARCHIVE_NAME=$(basename "$FIBERS_DIR").tar.gz
66+
echo "ARCHIVE_NAME=$ARCHIVE_NAME" >> $GITHUB_ENV
67+
tar -czf "$ARCHIVE_NAME" -C "$(dirname "$FIBERS_DIR")" "$(basename "$FIBERS_DIR")"
68+
69+
- name: Upload archive to release
70+
uses: softprops/action-gh-release@v1
71+
with:
72+
name: node-${{ env.NODE_VERSION }}-LATEST
73+
tag_name: node-${{ env.NODE_VERSION }}-release
74+
files: ${{ env.ARCHIVE_NAME }}
75+
env:
76+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Build node-packages with prebuilt Node
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- node20.18.3_dockerfile
8+
9+
jobs:
10+
build-packages:
11+
strategy:
12+
matrix:
13+
include:
14+
- platform: linux
15+
arch: x64
16+
runs_on: ubuntu-22.04
17+
- platform: linux
18+
arch: arm64
19+
runs_on: ubuntu-22.04-arm
20+
runs-on: ${{ matrix.runs_on }}
21+
22+
env:
23+
NODE_VERSION: v20.18.3
24+
25+
steps:
26+
- name: Debug Matrix Values
27+
run: |
28+
echo "Matrix platform: ${{ matrix.platform }}"
29+
echo "Matrix arch: ${{ matrix.arch }}"
30+
31+
- name: Download Node archive
32+
run: |
33+
gh release download node-${{ env.NODE_VERSION }}-release \
34+
--repo asana/node \
35+
--pattern "node-${{ env.NODE_VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}-LATEST.tar.xz"
36+
mv node-${{ env.NODE_VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}-LATEST.tar.xz node.tar.xz
37+
pwd
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
41+
- name: Download Dockerfile from GitHub API
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
run: |
45+
curl -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3.raw" -o Dockerfile.Packages https://api.github.com/repos/Asana/node/contents/Dockerfile.Packages?ref=node20.18.3_dockerfile
46+
cat Dockerfile.Packages
47+
pwd
48+
49+
- name: Execute the Dockerfile
50+
run: |
51+
pwd
52+
docker build -t node20_packages_build -f Dockerfile.Packages .
53+
54+
- name: Extract resources
55+
run: |
56+
docker create --name temp_node_packages_extract node20_packages_build
57+
docker cp temp_node_packages_extract:/usr/src/node/node_modules $GITHUB_WORKSPACE/node_modules
58+
docker rm temp_node_packages_extract
59+
60+
- name: Tar node-packages
61+
run: |
62+
mkdir -p ./bcrypt@5.1.0/node_modules/bcrypt
63+
mkdir -p ./cld@2.9.1/node_modules/cld
64+
mkdir -p ./unix-dgram@2.0.6/node_modules/unix-dgram
65+
mv node_modules/bcrypt ./bcrypt@5.1.0/node_modules/bcrypt
66+
mv node_modules/cld ./cld@2.9.1/node_modules/cld
67+
mv node_modules/unix-dgram ./unix-dgram@2.0.6/node_modules/unix-dgram
68+
tar --hard-dereference -cvzf packages_${{matrix.arch}}.tar.gz bcrypt@5.1.0 cld@2.9.1 unix-dgram@2.0.6
69+
70+
- name: Upload archive to release
71+
uses: softprops/action-gh-release@v1
72+
with:
73+
name: node-${{ env.NODE_VERSION }}-LATEST
74+
tag_name: node-${{ env.NODE_VERSION }}-release
75+
files: packages_${{matrix.arch}}.tar.gz
76+
env:
77+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/build-node.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: Build Node
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
build-node:
8+
name: Build ${{ matrix.platform }}-${{ matrix.arch }}
9+
strategy:
10+
matrix:
11+
include:
12+
- platform: linux
13+
arch: x64
14+
runs_on: ubuntu-22.04
15+
- platform: linux
16+
arch: arm64
17+
runs_on: ubuntu-22.04-arm
18+
runs-on: ${{ matrix.runs_on }}
19+
20+
env:
21+
S3_BUCKET: your-bucket-name
22+
AWS_REGION: us-east-1
23+
24+
steps:
25+
- name: Checkout Node fork
26+
uses: actions/checkout@v3
27+
with:
28+
repository: Asana/node
29+
path: node
30+
ref: ${{ github.event_name == 'pull_request' && format('refs/pull/{0}/merge', github.event.pull_request.number) || github.ref_name }}
31+
token: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Extract Node Version
34+
id: extract-node-version
35+
run: |
36+
NODE_MAJOR_VERSION=$(grep '#define NODE_MAJOR_VERSION' node/src/node_version.h | awk '{print $3}')
37+
NODE_MINOR_VERSION=$(grep '#define NODE_MINOR_VERSION' node/src/node_version.h | awk '{print $3}')
38+
NODE_PATCH_VERSION=$(grep '#define NODE_PATCH_VERSION' node/src/node_version.h | awk '{print $3}')
39+
NODE_VERSION="v${NODE_MAJOR_VERSION}.${NODE_MINOR_VERSION}.${NODE_PATCH_VERSION}"
40+
echo "NODE_VERSION=${NODE_VERSION}" >> $GITHUB_ENV
41+
42+
- name: Set build metadata
43+
id: meta
44+
working-directory: node
45+
run: |
46+
TIMESTAMP=$(date -u +%Y-%m-%dT%H-%M)
47+
SHORT_SHA=$(git rev-parse --short HEAD)
48+
echo "BUILD_ID=${TIMESTAMP}-${SHORT_SHA}" >> $GITHUB_ENV
49+
echo "build_id=${TIMESTAMP}-${SHORT_SHA}" >> $GITHUB_OUTPUT
50+
51+
#- name: Install dependencies (Linux)
52+
#if: matrix.platform == 'linux'
53+
#run: |
54+
#sudo apt-get update
55+
#sudo apt-get install -y python3 g++ make curl tar xz-utils
56+
57+
#- name: Build Node (linux)
58+
#working-directory: node
59+
#if: matrix.platform == 'linux'
60+
#run: |
61+
#./configure --experimental-enable-pointer-compression
62+
#make -j4 install DESTDIR=$GITHUB_WORKSPACE/node-install
63+
64+
#- name: Build Node (darwin)
65+
#working-directory: node
66+
#if: matrix.platform == 'darwin'
67+
#run: |
68+
#./configure --experimental-enable-pointer-compression --without-snapshot
69+
#make -j2 install DESTDIR=$GITHUB_WORKSPACE/node-install
70+
#
71+
72+
- name: Execute the Dockerfile
73+
working-directory: node
74+
run: |
75+
docker build -t node20_build -f ./Dockerfile.Node20 .
76+
77+
- name: Extract resources
78+
run: |
79+
docker create --name temp_node_extract node20_build
80+
docker cp temp_node_extract:/usr/src/node/node-install $GITHUB_WORKSPACE/node-install
81+
docker rm temp_node_extract
82+
83+
- name: Archive Node
84+
run: |
85+
mkdir -p artifacts
86+
FILENAME=node-${NODE_VERSION}-${{ matrix.platform }}-${{ matrix.arch }}-${{ steps.meta.outputs.build_id }}.tar.xz
87+
FILENAME_LATEST=node-${NODE_VERSION}-${{ matrix.platform }}-${{ matrix.arch }}-LATEST.tar.xz
88+
tar -C node-install -cJf artifacts/$FILENAME .
89+
cp artifacts/$FILENAME artifacts/$FILENAME_LATEST
90+
echo "NODE_ARCHIVE=$FILENAME" >> $GITHUB_ENV
91+
echo "NODE_ARCHIVE_LATEST=$FILENAME_LATEST" >> $GITHUB_ENV
92+
93+
- name: Upload Node archive
94+
uses: actions/upload-artifact@v4
95+
with:
96+
name: node-${{ env.NODE_VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}-${{ steps.meta.outputs.build_id }}
97+
path: artifacts/${{ env.NODE_ARCHIVE }}
98+
99+
- name: Upload Node archive latest
100+
uses: actions/upload-artifact@v4
101+
with:
102+
name: node-${{ env.NODE_VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}-LATEST
103+
path: artifacts/${{ env.NODE_ARCHIVE_LATEST }}
104+
105+
- name: Upload Node archive to release
106+
uses: softprops/action-gh-release@v1
107+
with:
108+
name: node-${{ env.NODE_VERSION }}-LATEST
109+
tag_name: node-${{ env.NODE_VERSION }}-release
110+
files: ./artifacts/${{ env.NODE_ARCHIVE_LATEST }}
111+
env:
112+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Dockerfile.Fibers

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Stage 1
2+
FROM ubuntu:20.04 AS base
3+
4+
# Set non-interactive mode to avoid prompts during installation
5+
ENV DEBIAN_FRONTEND=noninteractive
6+
7+
# Install necessary dependencies
8+
RUN apt-get update
9+
RUN apt-get install -y software-properties-common
10+
RUN add-apt-repository -y ppa:ubuntu-toolchain-r/test
11+
RUN apt-get update
12+
RUN apt-get install -y build-essential python3 python3-distutils g++-10 make curl git pkg-config libssl-dev libffi-dev libgmp-dev libtool autoconf automake cmake wget xz-utils unzip vim
13+
14+
# Copy local Node.js source into the image
15+
WORKDIR /usr/src/node
16+
COPY node.tar.xz .
17+
18+
RUN mkdir -p node-install && tar -C node-install -xJf node.tar.xz
19+
20+
ENV PATH="/usr/src/node/node-install/usr/local/bin:$PATH"
21+
22+
RUN which node
23+
RUN node -v
24+
RUN node -p "process.arch"
25+
RUN echo -------------------
26+
RUN git clone --branch jackstrohm_node20_fibers --depth 1 https://github.com/asana/node-fibers.git node-fibers
27+
28+
WORKDIR /usr/src/node/node-fibers
29+
RUN npm install --nodedir="/usr/src/node/node-install/usr/local"
30+
RUN npm test || true
31+
RUN rm bin/repl
32+
RUN find .
33+
34+
35+
CMD ["bash"]
36+

Dockerfile.Node20

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Stage 1
2+
FROM ubuntu:20.04 AS base
3+
4+
# Set non-interactive mode to avoid prompts during installation
5+
ENV DEBIAN_FRONTEND=noninteractive
6+
7+
# Install necessary dependencies
8+
RUN apt-get update
9+
RUN apt-get install -y software-properties-common
10+
RUN add-apt-repository -y ppa:ubuntu-toolchain-r/test
11+
RUN apt-get update && apt-get install -y build-essential python3 python3-distutils g++-10 make curl git pkg-config libssl-dev libffi-dev libgmp-dev libtool autoconf automake cmake wget xz-utils unzip vim
12+
RUN rm -rf /var/lib/apt/lists/*
13+
14+
# Set g++ 10 as the default
15+
RUN update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 100
16+
17+
# Copy local Node.js source into the image
18+
WORKDIR /usr/src/node
19+
COPY . .
20+
21+
RUN ./configure --experimental-enable-pointer-compression
22+
RUN make -j4 install DESTDIR=./node-install
23+
24+
CMD ["bash"]
25+

Dockerfile.Packages

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Stage 1
2+
FROM ubuntu:20.04 AS base
3+
4+
# Set non-interactive mode to avoid prompts during installation
5+
ENV DEBIAN_FRONTEND=noninteractive
6+
7+
# Install necessary dependencies
8+
RUN apt-get update
9+
RUN apt-get install -y software-properties-common
10+
RUN add-apt-repository -y ppa:ubuntu-toolchain-r/test
11+
RUN apt-get update
12+
RUN apt-get install -y build-essential python3 python3-distutils g++-10 make curl git pkg-config libssl-dev libffi-dev libgmp-dev libtool autoconf automake cmake wget xz-utils unzip vim
13+
14+
# Copy local Node.js source into the image
15+
WORKDIR /usr/src/node
16+
COPY node.tar.xz .
17+
18+
RUN mkdir -p node-install && tar -C node-install -xJf node.tar.xz
19+
20+
ENV PATH="/usr/src/node/node-install/usr/local/bin:$PATH"
21+
22+
RUN which node
23+
RUN node -v
24+
RUN node -p "process.arch"
25+
RUN echo -------------------
26+
27+
RUN npm i --nodedir="/usr/src/node/node-install/usr/local" bcrypt@5.1.0
28+
RUN npm i --nodedir="/usr/src/node/node-install/usr/local" cld@2.9.1
29+
RUN npm i --nodedir="/usr/src/node/node-install/usr/local" unix-dgram@2.0.6
30+
31+
RUN ls
32+
RUN ls node_modules
33+
34+
CMD ["bash"]
35+

stage_for_s3.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ curl "https://asana-oss-cache.s3.us-east-1.amazonaws.com/node-fibers/fibers-5.0.
1414
tar -xzf fibers-5.0.4.tar.gz
1515
rm fibers-5.0.4.tar.gz
1616

17-
find . -name "*.gz" | while read -r a
17+
find . -name "linux-*.gz" | while read -r a
1818
do
1919
tar -xzf "$a" -C package/bin
2020
rm "$a"

0 commit comments

Comments
 (0)