diff --git a/.github/workflows/build-node-fibers.yml b/.github/workflows/build-node-fibers.yml new file mode 100644 index 00000000000000..19b07de06735a0 --- /dev/null +++ b/.github/workflows/build-node-fibers.yml @@ -0,0 +1,76 @@ +name: Build node-fibers with prebuilt Node + +on: + workflow_dispatch: + push: + branches: + - node20.18.3_dockerfile + +jobs: + build-fibers: + strategy: + matrix: + include: + - platform: linux + arch: x64 + runs_on: ubuntu-22.04 + - platform: linux + arch: arm64 + runs_on: ubuntu-22.04-arm + runs-on: ${{ matrix.runs_on }} + + env: + NODE_VERSION: v20.18.3 + + steps: + - name: Debug Matrix Values + run: | + echo "Matrix platform: ${{ matrix.platform }}" + echo "Matrix arch: ${{ matrix.arch }}" + + - name: Download Node archive + run: | + gh release download node-${{ env.NODE_VERSION }}-release \ + --repo asana/node \ + --pattern "node-${{ env.NODE_VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}-LATEST.tar.xz" + mv node-${{ env.NODE_VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}-LATEST.tar.xz node.tar.xz + pwd + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Download Dockerfile from GitHub API + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + 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 + cat Dockerfile.Fibers + pwd + + - name: Execute the Dockerfile + run: | + pwd + docker build -t node20_fibers_build -f Dockerfile.Fibers . + + - name: Extract resources + run: | + docker create --name temp_node_fibers_extract node20_fibers_build + docker cp temp_node_fibers_extract:/usr/src/node/node-fibers $GITHUB_WORKSPACE/node-fibers + docker rm temp_node_fibers_extract + + - name: Find and archive fibers.node + run: | + # Find the directory under bin/ that contains fibers.node + FIBERS_PATH=$(find ./node-fibers/bin -type f -name fibers.node | head -n1) + FIBERS_DIR=$(dirname "$FIBERS_PATH") + ARCHIVE_NAME=$(basename "$FIBERS_DIR").tar.gz + echo "ARCHIVE_NAME=$ARCHIVE_NAME" >> $GITHUB_ENV + tar -czf "$ARCHIVE_NAME" -C "$(dirname "$FIBERS_DIR")" "$(basename "$FIBERS_DIR")" + + - name: Upload archive to release + uses: softprops/action-gh-release@v1 + with: + name: node-${{ env.NODE_VERSION }}-LATEST + tag_name: node-${{ env.NODE_VERSION }}-release + files: ${{ env.ARCHIVE_NAME }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/build-node-packages.yml b/.github/workflows/build-node-packages.yml new file mode 100644 index 00000000000000..2ef0171b59b0ae --- /dev/null +++ b/.github/workflows/build-node-packages.yml @@ -0,0 +1,77 @@ +name: Build node-packages with prebuilt Node + +on: + workflow_dispatch: + push: + branches: + - node20.18.3_dockerfile + +jobs: + build-packages: + strategy: + matrix: + include: + - platform: linux + arch: x64 + runs_on: ubuntu-22.04 + - platform: linux + arch: arm64 + runs_on: ubuntu-22.04-arm + runs-on: ${{ matrix.runs_on }} + + env: + NODE_VERSION: v20.18.3 + + steps: + - name: Debug Matrix Values + run: | + echo "Matrix platform: ${{ matrix.platform }}" + echo "Matrix arch: ${{ matrix.arch }}" + + - name: Download Node archive + run: | + gh release download node-${{ env.NODE_VERSION }}-release \ + --repo asana/node \ + --pattern "node-${{ env.NODE_VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}-LATEST.tar.xz" + mv node-${{ env.NODE_VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}-LATEST.tar.xz node.tar.xz + pwd + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Download Dockerfile from GitHub API + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + 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 + cat Dockerfile.Packages + pwd + + - name: Execute the Dockerfile + run: | + pwd + docker build -t node20_packages_build -f Dockerfile.Packages . + + - name: Extract resources + run: | + docker create --name temp_node_packages_extract node20_packages_build + docker cp temp_node_packages_extract:/usr/src/node/node_modules $GITHUB_WORKSPACE/node_modules + docker rm temp_node_packages_extract + + - name: Tar node-packages + run: | + mkdir -p ./bcrypt@5.1.0/node_modules/bcrypt + mkdir -p ./cld@2.9.1/node_modules/cld + mkdir -p ./unix-dgram@2.0.6/node_modules/unix-dgram + mv node_modules/bcrypt ./bcrypt@5.1.0/node_modules/bcrypt + mv node_modules/cld ./cld@2.9.1/node_modules/cld + mv node_modules/unix-dgram ./unix-dgram@2.0.6/node_modules/unix-dgram + tar --hard-dereference -cvzf packages_${{matrix.arch}}.tar.gz bcrypt@5.1.0 cld@2.9.1 unix-dgram@2.0.6 + + - name: Upload archive to release + uses: softprops/action-gh-release@v1 + with: + name: node-${{ env.NODE_VERSION }}-LATEST + tag_name: node-${{ env.NODE_VERSION }}-release + files: packages_${{matrix.arch}}.tar.gz + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/build-node.yml b/.github/workflows/build-node.yml new file mode 100644 index 00000000000000..e6261d91f71694 --- /dev/null +++ b/.github/workflows/build-node.yml @@ -0,0 +1,112 @@ +name: Build Node + +on: + workflow_dispatch: + +jobs: + build-node: + name: Build ${{ matrix.platform }}-${{ matrix.arch }} + strategy: + matrix: + include: + - platform: linux + arch: x64 + runs_on: ubuntu-22.04 + - platform: linux + arch: arm64 + runs_on: ubuntu-22.04-arm + runs-on: ${{ matrix.runs_on }} + + env: + S3_BUCKET: your-bucket-name + AWS_REGION: us-east-1 + + steps: + - name: Checkout Node fork + uses: actions/checkout@v3 + with: + repository: Asana/node + path: node + ref: ${{ github.event_name == 'pull_request' && format('refs/pull/{0}/merge', github.event.pull_request.number) || github.ref_name }} + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract Node Version + id: extract-node-version + run: | + NODE_MAJOR_VERSION=$(grep '#define NODE_MAJOR_VERSION' node/src/node_version.h | awk '{print $3}') + NODE_MINOR_VERSION=$(grep '#define NODE_MINOR_VERSION' node/src/node_version.h | awk '{print $3}') + NODE_PATCH_VERSION=$(grep '#define NODE_PATCH_VERSION' node/src/node_version.h | awk '{print $3}') + NODE_VERSION="v${NODE_MAJOR_VERSION}.${NODE_MINOR_VERSION}.${NODE_PATCH_VERSION}" + echo "NODE_VERSION=${NODE_VERSION}" >> $GITHUB_ENV + + - name: Set build metadata + id: meta + working-directory: node + run: | + TIMESTAMP=$(date -u +%Y-%m-%dT%H-%M) + SHORT_SHA=$(git rev-parse --short HEAD) + echo "BUILD_ID=${TIMESTAMP}-${SHORT_SHA}" >> $GITHUB_ENV + echo "build_id=${TIMESTAMP}-${SHORT_SHA}" >> $GITHUB_OUTPUT + + #- name: Install dependencies (Linux) + #if: matrix.platform == 'linux' + #run: | + #sudo apt-get update + #sudo apt-get install -y python3 g++ make curl tar xz-utils + + #- name: Build Node (linux) + #working-directory: node + #if: matrix.platform == 'linux' + #run: | + #./configure --experimental-enable-pointer-compression + #make -j4 install DESTDIR=$GITHUB_WORKSPACE/node-install + + #- name: Build Node (darwin) + #working-directory: node + #if: matrix.platform == 'darwin' + #run: | + #./configure --experimental-enable-pointer-compression --without-snapshot + #make -j2 install DESTDIR=$GITHUB_WORKSPACE/node-install + # + + - name: Execute the Dockerfile + working-directory: node + run: | + docker build -t node20_build -f ./Dockerfile.Node20 . + + - name: Extract resources + run: | + docker create --name temp_node_extract node20_build + docker cp temp_node_extract:/usr/src/node/node-install $GITHUB_WORKSPACE/node-install + docker rm temp_node_extract + + - name: Archive Node + run: | + mkdir -p artifacts + FILENAME=node-${NODE_VERSION}-${{ matrix.platform }}-${{ matrix.arch }}-${{ steps.meta.outputs.build_id }}.tar.xz + FILENAME_LATEST=node-${NODE_VERSION}-${{ matrix.platform }}-${{ matrix.arch }}-LATEST.tar.xz + tar -C node-install -cJf artifacts/$FILENAME . + cp artifacts/$FILENAME artifacts/$FILENAME_LATEST + echo "NODE_ARCHIVE=$FILENAME" >> $GITHUB_ENV + echo "NODE_ARCHIVE_LATEST=$FILENAME_LATEST" >> $GITHUB_ENV + + - name: Upload Node archive + uses: actions/upload-artifact@v4 + with: + name: node-${{ env.NODE_VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}-${{ steps.meta.outputs.build_id }} + path: artifacts/${{ env.NODE_ARCHIVE }} + + - name: Upload Node archive latest + uses: actions/upload-artifact@v4 + with: + name: node-${{ env.NODE_VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}-LATEST + path: artifacts/${{ env.NODE_ARCHIVE_LATEST }} + + - name: Upload Node archive to release + uses: softprops/action-gh-release@v1 + with: + name: node-${{ env.NODE_VERSION }}-LATEST + tag_name: node-${{ env.NODE_VERSION }}-release + files: ./artifacts/${{ env.NODE_ARCHIVE_LATEST }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Dockerfile.Fibers b/Dockerfile.Fibers new file mode 100644 index 00000000000000..851671619f33b9 --- /dev/null +++ b/Dockerfile.Fibers @@ -0,0 +1,36 @@ +# Stage 1 +FROM ubuntu:20.04 AS base + +# Set non-interactive mode to avoid prompts during installation +ENV DEBIAN_FRONTEND=noninteractive + +# Install necessary dependencies +RUN apt-get update +RUN apt-get install -y software-properties-common +RUN add-apt-repository -y ppa:ubuntu-toolchain-r/test +RUN apt-get update +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 + +# Copy local Node.js source into the image +WORKDIR /usr/src/node +COPY node.tar.xz . + +RUN mkdir -p node-install && tar -C node-install -xJf node.tar.xz + +ENV PATH="/usr/src/node/node-install/usr/local/bin:$PATH" + +RUN which node +RUN node -v +RUN node -p "process.arch" +RUN echo ------------------- +RUN git clone --branch jackstrohm_node20_fibers --depth 1 https://github.com/asana/node-fibers.git node-fibers + +WORKDIR /usr/src/node/node-fibers +RUN npm install --nodedir="/usr/src/node/node-install/usr/local" +RUN npm test || true +RUN rm bin/repl +RUN find . + + +CMD ["bash"] + diff --git a/Dockerfile.Node20 b/Dockerfile.Node20 new file mode 100644 index 00000000000000..b80bfc783121ab --- /dev/null +++ b/Dockerfile.Node20 @@ -0,0 +1,25 @@ +# Stage 1 +FROM ubuntu:20.04 AS base + +# Set non-interactive mode to avoid prompts during installation +ENV DEBIAN_FRONTEND=noninteractive + +# Install necessary dependencies +RUN apt-get update +RUN apt-get install -y software-properties-common +RUN add-apt-repository -y ppa:ubuntu-toolchain-r/test +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 +RUN rm -rf /var/lib/apt/lists/* + +# Set g++ 10 as the default +RUN update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 100 + +# Copy local Node.js source into the image +WORKDIR /usr/src/node +COPY . . + +RUN ./configure --experimental-enable-pointer-compression +RUN make -j4 install DESTDIR=./node-install + +CMD ["bash"] + diff --git a/Dockerfile.Packages b/Dockerfile.Packages new file mode 100644 index 00000000000000..bb5c74497907cf --- /dev/null +++ b/Dockerfile.Packages @@ -0,0 +1,35 @@ +# Stage 1 +FROM ubuntu:20.04 AS base + +# Set non-interactive mode to avoid prompts during installation +ENV DEBIAN_FRONTEND=noninteractive + +# Install necessary dependencies +RUN apt-get update +RUN apt-get install -y software-properties-common +RUN add-apt-repository -y ppa:ubuntu-toolchain-r/test +RUN apt-get update +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 + +# Copy local Node.js source into the image +WORKDIR /usr/src/node +COPY node.tar.xz . + +RUN mkdir -p node-install && tar -C node-install -xJf node.tar.xz + +ENV PATH="/usr/src/node/node-install/usr/local/bin:$PATH" + +RUN which node +RUN node -v +RUN node -p "process.arch" +RUN echo ------------------- + +RUN npm i --nodedir="/usr/src/node/node-install/usr/local" bcrypt@5.1.0 +RUN npm i --nodedir="/usr/src/node/node-install/usr/local" cld@2.9.1 +RUN npm i --nodedir="/usr/src/node/node-install/usr/local" unix-dgram@2.0.6 + +RUN ls +RUN ls node_modules + +CMD ["bash"] + diff --git a/stage_for_s3.bash b/stage_for_s3.bash index d1642b91543bd0..32bb99f153b7ab 100755 --- a/stage_for_s3.bash +++ b/stage_for_s3.bash @@ -13,7 +13,7 @@ gh release download -p "*.xz" curl "https://asana-oss-cache.s3.us-east-1.amazonaws.com/node-fibers/fibers-5.0.4.pc.tgz" --output fibers-5.0.4.tar.gz tar -xzf fibers-5.0.4.tar.gz -find . -name "*.gz" | while read -r a +find . -name "linux-*.gz" | while read -r a do tar -xzf "$a" -C package/bin rm "$a" @@ -44,7 +44,7 @@ for file in *.tar.xz; do echo "Target Dir: $target_dir" mkdir "$target_dir" tar -xzf "$new_name" -C "$target_dir" - mv "$target_dir/usr/local/*" "$target_dir" + mv $target_dir/usr/local/* "$target_dir" rm -fr "$target_dir/usr/local" tar -cJf "$new_name" "$target_dir"