Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build for arm64 too #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
48 changes: 40 additions & 8 deletions .github/workflows/build-release-alpine-nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,31 @@ jobs:
build:
name: Build node.js ${{github.event.inputs.NodeVersion}}
runs-on: ubuntu-latest
strategy:
matrix:
arch: ['x64', 'arm64']
steps:
- uses: actions/checkout@v3
- name: Build the Docker image
run: |
NodeVersion="${{github.event.inputs.NodeVersion}}"
PythonVersion="python3"
Arch="${{matrix.arch}}"
if [[ $NodeVersion = v12* ]]
then
PythonVersion="python2"
fi

DockerPlatform="linux/amd64"
if [[ $Arch = arm64 ]]
then
DockerPlatform="linux/arm64"
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 .
echo arch $Arch
docker build --file Dockerfile --tag alpine_nodejs:${{github.event.inputs.NodeVersion}} --build-arg NodeVersion=${{github.event.inputs.NodeVersion}} --build-arg PythonVersion=$PythonVersion --build-arg Arch=$Arch --platform $DockerPlatform .
- name: Copy alpine node.js out
run: |
mkdir $RUNNER_TEMP/alpine_node
Expand All @@ -34,22 +46,29 @@ jobs:
- name: Upload alpine node.js
uses: actions/upload-artifact@v3
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}}
needs: [build]
runs-on: ubuntu-latest
strategy:
matrix:
include:
- arch: x64
runs-on: ubuntu-latest
- arch: arm64
runs-on: ubuntu-latest # TODO: Add and use an ARM64 runner

Choose a reason for hiding this comment

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

runs-on: ${{matrix.runs-on}}
container: alpine
steps:
- name: Download alpine node.js
uses: actions/download-artifact@v3
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,10 +80,14 @@ jobs:
needs: [test]
runs-on: ubuntu-latest
steps:
- name: Download alpine node.js
- name: Download x64 alpine node.js
uses: actions/download-artifact@v3
with:
name: alpine_nodejs_${{github.event.inputs.NodeVersion}}_x64
- name: Download arm64 alpine node.js
uses: actions/download-artifact@v3
with:
name: alpine_nodejs_${{github.event.inputs.NodeVersion}}
name: alpine_nodejs_${{github.event.inputs.NodeVersion}}_arm64
# Create GitHub release
- uses: actions/create-release@master
id: createRelease
Expand All @@ -86,3 +109,12 @@ jobs:
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
- name: Upload Release Asset # TODO: Verify if this works
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.createRelease.outputs.upload_url }}
asset_path: ${{ github.workspace }}/node-${{github.event.inputs.NodeVersion}}-alpine-arm64.tar.gz
asset_name: node-${{github.event.inputs.NodeVersion}}-alpine-arm64.tar.gz
asset_content_type: application/octet-stream
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 Arch

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=$Arch --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-$Arch.tar.gz ./bin ./LICENSE && rm -rf ./bin ./LICENSE
RUN cp ./node-$NodeVersion-alpine-$Arch.tar.gz /node_staging/node-$NodeVersion-alpine-$Arch.tar.gz && ls -l /node_staging

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