Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 37 additions & 28 deletions .github/workflows/build-release-alpine-nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@ on:

jobs:
build:
name: Build node.js ${{github.event.inputs.NodeVersion}}
runs-on: ubuntu-latest
name: Build node.js ${{github.event.inputs.NodeVersion}} (${{matrix.arch}})
runs-on: ${{matrix.runner}}
strategy:
matrix:
include:
- arch: x64
runner: ubuntu-latest
- arch: arm64
runner: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v3
- name: Build the Docker image
Expand All @@ -25,7 +32,11 @@ jobs:
fi
echo node.js version $NodeVersion
echo python version $PythonVersion
docker build --file Dockerfile --tag alpine_nodejs:${{github.event.inputs.NodeVersion}} --build-arg NodeVersion=${{github.event.inputs.NodeVersion}} --build-arg PythonVersion=$PythonVersion .
docker build --file Dockerfile --tag alpine_nodejs:${{github.event.inputs.NodeVersion}} \
--build-arg NodeVersion=${{github.event.inputs.NodeVersion}} \
--build-arg PythonVersion=$PythonVersion \
--build-arg NodeArch=${{matrix.arch}} \
.
- name: Copy alpine node.js out
run: |
mkdir $RUNNER_TEMP/alpine_node
Expand All @@ -34,22 +45,31 @@ jobs:
- name: Upload alpine node.js
uses: actions/upload-artifact@v4
with:
name: alpine_nodejs_${{github.event.inputs.NodeVersion}}
path: ${{runner.temp}}/alpine_node/node-${{github.event.inputs.NodeVersion}}-alpine-x64.tar.gz
name: alpine_nodejs_${{github.event.inputs.NodeVersion}}_${{matrix.arch}}
path: ${{runner.temp}}/alpine_node/node-${{github.event.inputs.NodeVersion}}-alpine-${{matrix.arch}}.tar.gz

test:
name: Test node.js ${{github.event.inputs.NodeVersion}}
name: Test node.js ${{github.event.inputs.NodeVersion}} (${{matrix.arch}})
needs: [build]
runs-on: ubuntu-latest
runs-on: ${{matrix.runner}}
strategy:
matrix:
include:
- arch: x64
runner: ubuntu-latest
# TODO enable running the tests on arm64 once actions/runner supports Alpine arm64
# https://github.com/actions/runner/pull/3665
#- arch: arm64
# runner: ubuntu-24.04-arm
Comment on lines +60 to +63
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like running the tests will have to wait until actions/runner#3665 is merged, because they obviously fail due to the block in the actions/runner repo.

container: alpine
steps:
- name: Download alpine node.js
uses: actions/download-artifact@v4
with:
name: alpine_nodejs_${{github.event.inputs.NodeVersion}}
name: alpine_nodejs_${{github.event.inputs.NodeVersion}}_${{matrix.arch}}
- run: |
ls -l
tar xzf ./node-${{github.event.inputs.NodeVersion}}-alpine-x64.tar.gz
tar xzf ./node-${{github.event.inputs.NodeVersion}}-alpine-${{matrix.arch}}.tar.gz
ls -l -R
./bin/node -v
./bin/node -e "console.log('hello world')"
Expand All @@ -61,28 +81,17 @@ jobs:
needs: [test]
runs-on: ubuntu-latest
steps:
- name: Download alpine node.js
- name: Download alpine node.js (x64 and arm64)
uses: actions/download-artifact@v4
with:
name: alpine_nodejs_${{github.event.inputs.NodeVersion}}
# Create GitHub release
- uses: actions/create-release@master
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This action is unmaintained and the repo has been archived: https://github.com/actions/create-release

id: createRelease
name: Create node.js ${{github.event.inputs.NodeVersion}} Alpine Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
pattern: alpine_nodejs_${{github.event.inputs.NodeVersion}}_*
merge-multiple: true
- name: Release
uses: softprops/action-gh-release@v2
with:
tag_name: "${{github.event.inputs.NodeVersion}}"
release_name: "${{github.event.inputs.NodeVersion}}"
name: "${{github.event.inputs.NodeVersion}}"
body: |
Alpine node.js ${{github.event.inputs.NodeVersion}}
# Upload release assets
- name: Upload Release Asset
uses: actions/[email protected]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This action in unmaintained and the repo has been archived: https://github.com/actions/upload-release-asset

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.createRelease.outputs.upload_url }}
asset_path: ${{ github.workspace }}/node-${{github.event.inputs.NodeVersion}}-alpine-x64.tar.gz
asset_name: node-${{github.event.inputs.NodeVersion}}-alpine-x64.tar.gz
asset_content_type: application/octet-stream
files: |
node-*-alpine-*.tar.gz
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM alpine
ARG NodeVersion
ARG PythonVersion
ARG NodeArch

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
Expand All @@ -11,16 +12,16 @@ RUN apk add --no-cache --virtual .build-deps binutils-gold curl g++ gcc gnupg li

# donwload and compile node from source code.
RUN wget https://nodejs.org/dist/$NodeVersion/node-$NodeVersion.tar.gz && tar -zxvf node-$NodeVersion.tar.gz
RUN cd node-$NodeVersion && ./configure --dest-cpu=x64 --partly-static && make -j$(getconf _NPROCESSORS_ONLN)
RUN cd node-$NodeVersion && ./configure --dest-cpu=$NodeArch --partly-static && make -j$(getconf _NPROCESSORS_ONLN)

# create and copy tar.gz into /node_staging
RUN mkdir -p /usr/src/out/bin
RUN mkdir -p /node_staging
WORKDIR /usr/src/out
RUN cp /usr/src/app/node-$NodeVersion/out/Release/node /usr/src/out/bin/node
RUN cp /usr/src/app/node-$NodeVersion/LICENSE /usr/src/out/LICENSE
RUN tar -czvf node-$NodeVersion-alpine-x64.tar.gz ./bin ./LICENSE && rm -rf ./bin ./LICENSE
RUN cp ./node-$NodeVersion-alpine-x64.tar.gz /node_staging/node-$NodeVersion-alpine-x64.tar.gz && ls -l /node_staging
RUN tar -czvf node-$NodeVersion-alpine-$NodeArch.tar.gz ./bin ./LICENSE && rm -rf ./bin ./LICENSE
RUN cp ./node-$NodeVersion-alpine-$NodeArch.tar.gz /node_staging/node-$NodeVersion-alpine-$NodeArch.tar.gz && ls -l /node_staging

# copy the tar.gz into the mapped in volume
CMD ["cp", "-v", "-a", "/node_staging/.", "/node_output/"]