Merge pull request #662 from napi-rs/linux-musl-builder
ci: add musl-cross toolchains into alpine.Dockerfile
This commit is contained in:
commit
382e824b39
7 changed files with 121 additions and 12 deletions
2
.github/workflows/docker.yaml
vendored
2
.github/workflows/docker.yaml
vendored
|
@ -29,7 +29,7 @@ jobs:
|
|||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
file: alpine.Dockerfile
|
||||
platforms: linux/amd64,linux/arm64
|
||||
platforms: linux/amd64
|
||||
push: true
|
||||
tags: ghcr.io/${{ github.repository }}/nodejs-rust:lts-alpine
|
||||
|
||||
|
|
89
.github/workflows/linux-aarch64-musl.yaml
vendored
Normal file
89
.github/workflows/linux-aarch64-musl.yaml
vendored
Normal file
|
@ -0,0 +1,89 @@
|
|||
name: Linux-aarch64-musl
|
||||
|
||||
env:
|
||||
DEBUG: 'napi:*'
|
||||
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: 'aarch64-linux-musl-gcc'
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: stable - aarch64-unknown-linux-gnu - node@14
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
steps:
|
||||
- run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 14
|
||||
check-latest: true
|
||||
|
||||
- name: Install
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
profile: minimal
|
||||
override: true
|
||||
|
||||
- name: Install aarch64 toolchain
|
||||
run: rustup target add aarch64-unknown-linux-gnu
|
||||
|
||||
- name: Generate Cargo.lock
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: generate-lockfile
|
||||
|
||||
- name: Cache cargo registry
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/.cargo/registry
|
||||
key: stable-linux-aarch64-gnu-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: Cache cargo index
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/.cargo/git
|
||||
key: stable-linux-aarch64-gnu-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: Cache NPM dependencies
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: node_modules
|
||||
key: npm-cache-linux-aarch64-gnu-node@14-${{ hashFiles('yarn.lock') }}
|
||||
|
||||
- name: Install dependencies
|
||||
run: yarn install --frozen-lockfile --ignore-platform --registry https://registry.npmjs.org --network-timeout 300000
|
||||
|
||||
- name: 'Build TypeScript'
|
||||
run: yarn build
|
||||
|
||||
- name: Pull docker image
|
||||
run: |
|
||||
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD $DOCKER_REGISTRY_URL
|
||||
docker pull $DOCKER_REGISTRY_URL/${{ github.repository }}/nodejs-rust:lts-alpine
|
||||
docker tag $DOCKER_REGISTRY_URL/${{ github.repository }}/nodejs-rust:lts-alpine builder
|
||||
env:
|
||||
DOCKER_REGISTRY_URL: ghcr.io
|
||||
DOCKER_USERNAME: ${{ github.actor }}
|
||||
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Cross build native tests
|
||||
run: |
|
||||
docker run -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v $(pwd):/napi-rs -w /napi-rs -e CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-musl-gcc builder yarn --cwd ./test_module build --target aarch64-unknown-linux-musl
|
||||
|
||||
- name: Setup and run tests
|
||||
uses: docker://multiarch/alpine:aarch64-latest-stable
|
||||
with:
|
||||
args: >
|
||||
sh -c "
|
||||
apk add nodejs yarn && \
|
||||
yarn test
|
||||
"
|
2
.github/workflows/linux-aarch64.yaml
vendored
2
.github/workflows/linux-aarch64.yaml
vendored
|
@ -63,7 +63,7 @@ jobs:
|
|||
run: sudo apt-get install gcc-9-aarch64-linux-gnu g++-9-aarch64-linux-gnu -y
|
||||
|
||||
- name: Install dependencies
|
||||
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
|
||||
run: yarn install --frozen-lockfile --ignore-platform --registry https://registry.npmjs.org --network-timeout 300000
|
||||
|
||||
- name: 'Build TypeScript'
|
||||
run: yarn build
|
||||
|
|
2
.github/workflows/linux-armv7.yaml
vendored
2
.github/workflows/linux-armv7.yaml
vendored
|
@ -63,7 +63,7 @@ jobs:
|
|||
run: sudo apt-get install gcc-9-arm-linux-gnueabihf -y
|
||||
|
||||
- name: Install dependencies
|
||||
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
|
||||
run: yarn install --frozen-lockfile --ignore-platform --registry https://registry.npmjs.org --network-timeout 300000
|
||||
|
||||
- name: 'Build TypeScript'
|
||||
run: yarn build
|
||||
|
|
2
.github/workflows/test.yaml
vendored
2
.github/workflows/test.yaml
vendored
|
@ -60,7 +60,7 @@ jobs:
|
|||
key: npm-cache-${{ matrix.os }}-node@${{ matrix.node }}-${{ hashFiles('yarn.lock') }}
|
||||
|
||||
- name: 'Install dependencies'
|
||||
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
|
||||
run: yarn install --frozen-lockfile --ignore-platform --registry https://registry.npmjs.org --network-timeout 300000
|
||||
|
||||
- name: 'Build TypeScript'
|
||||
run: yarn build
|
||||
|
|
|
@ -1,11 +1,30 @@
|
|||
FROM node:lts-alpine
|
||||
|
||||
ENV RUSTFLAGS="-C target-feature=-crt-static" \
|
||||
PATH="/usr/local/cargo/bin/rustup:/root/.cargo/bin:$PATH" \
|
||||
ENV PATH="/aarch64-linux-musl-cross/bin:/usr/local/cargo/bin/rustup:/root/.cargo/bin:$PATH" \
|
||||
RUSTFLAGS="-C target-feature=-crt-static" \
|
||||
CC="clang" \
|
||||
CXX="clang++"
|
||||
CXX="clang++" \
|
||||
GN_EXE=gn
|
||||
|
||||
RUN sed -i -e 's/v[[:digit:]]\..*\//edge\//g' /etc/apk/repositories && \
|
||||
apk update && \
|
||||
apk add rustup musl-dev build-base && \
|
||||
rustup-init -y
|
||||
RUN apk add --update --no-cache musl-dev && \
|
||||
sed -i -e 's/v[[:digit:]]\..*\//edge\//g' /etc/apk/repositories && \
|
||||
apk add --update --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing \
|
||||
rustup \
|
||||
bash \
|
||||
python3 \
|
||||
python2 \
|
||||
git \
|
||||
build-base \
|
||||
wget \
|
||||
clang \
|
||||
llvm \
|
||||
gn \
|
||||
tar \
|
||||
ninja
|
||||
|
||||
RUN rustup-init -y && \
|
||||
yarn global add pnpm && \
|
||||
rustup target add aarch64-unknown-linux-musl && \
|
||||
wget https://musl.cc/aarch64-linux-musl-cross.tgz && \
|
||||
tar -xvf aarch64-linux-musl-cross.tgz && \
|
||||
rm aarch64-linux-musl-cross.tgz
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
"include": ["."],
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist",
|
||||
"rootDir": "__test__"
|
||||
"rootDir": "__test__",
|
||||
"target": "ES2015"
|
||||
},
|
||||
"exclude": ["dist"]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue