Add workflows for Alpine binaries

This commit is contained in:
Jesse Chan 2021-04-12 20:30:20 +08:00
parent ae15753d5f
commit 07b80947e2
3 changed files with 88 additions and 0 deletions

5
.dockerignore Normal file
View File

@ -0,0 +1,5 @@
.*
dist
Dockerfile.*
lib-es5
node_modules

46
.github/workflows/build-alpine.yml vendored Normal file
View File

@ -0,0 +1,46 @@
name: Build Node binaries for Alpine
on:
workflow_dispatch:
jobs:
alpine:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
target-node: [8, 10, 12, 14]
target-arch: [x64, arm64]
include:
- target-arch: x64
target-toolchain: x86_64
- target-arch: arm64
target-toolchain: aarch64
steps:
- uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build
uses: docker/build-push-action@v2
with:
build-args: |
TARGET_TOOLCHAIN_ARCH=${{ matrix.target-toolchain }}
PKG_FETCH_OPTION_a=${{ matrix.target-arch }}
PKG_FETCH_OPTION_n=node${{ matrix.target-node }}
context: .
file: ./Dockerfile.alpine
platforms: linux/amd64
outputs: type=tar,dest=../out.tar
- name: Extract binaries from Docker image
run: |
tar xvf ../out.tar root/pkg-fetch/dist
- uses: actions/upload-artifact@v2
with:
name: node${{ matrix.target-node }}-alpine-${{ matrix.target-arch }}
path: root/pkg-fetch/dist/*

37
Dockerfile.alpine Normal file
View File

@ -0,0 +1,37 @@
ARG TARGET_TOOLCHAIN_ARCH
FROM muslcc/x86_64:$TARGET_TOOLCHAIN_ARCH-linux-musl
ARG PKG_FETCH_OPTION_a
ARG PKG_FETCH_OPTION_n
USER root:root
WORKDIR /root/pkg-fetch/
RUN apk add --no-cache build-base git linux-headers npm python2 python3 yarn
# https://gitlab.alpinelinux.org/alpine/aports/-/issues/8626
ENV CFLAGS=-U_FORTIFY_SOURCE
ENV CFLAGS_host=-U_FORTIFY_SOURCE
ENV CXXFLAGS=-U_FORTIFY_SOURCE
ENV CXXFLAGS_host=-U_FORTIFY_SOURCE
ENV CC=/bin/gcc
ENV CXX=/bin/g++
ENV AR=/bin/ar
ENV NM=/bin/nm
ENV READELF=/bin/readelf
ENV STRIP=/bin/strip
ENV CC_host=/usr/bin/gcc
ENV CXX_host=/usr/bin/g++
ENV AR_host=/usr/bin/ar
ENV NM_host=/usr/bin/nm
ENV READELF_host=/usr/bin/readelf
COPY . ./
RUN yarn install
RUN yarn start --force-build --arch $PKG_FETCH_OPTION_a --node-range $PKG_FETCH_OPTION_n --output dist