Skip to content

Commit

Permalink
ci: revive cross compile
Browse files Browse the repository at this point in the history
  • Loading branch information
baparham committed Feb 24, 2023
1 parent de53837 commit d1737e2
Show file tree
Hide file tree
Showing 11 changed files with 185 additions and 186 deletions.
44 changes: 0 additions & 44 deletions .github/workflows/arm64-alpine.yml

This file was deleted.

43 changes: 0 additions & 43 deletions .github/workflows/arm64-linux.yml

This file was deleted.

55 changes: 0 additions & 55 deletions .github/workflows/arm64-linuxstatic.yml

This file was deleted.

35 changes: 0 additions & 35 deletions .github/workflows/arm64-macos.yml

This file was deleted.

14 changes: 13 additions & 1 deletion .github/workflows/build-alpine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ jobs:
fail-fast: false
matrix:
target-node: [14, 16, 18, 19]
target-arch: [x64, arm64]
include:
- target-arch: x64
target-triple: x86_64-linux-musl
host-arch: x86_64
- target-arch: arm64
target-triple: aarch64-linux-musl
host-arch: x86_64

steps:
- uses: actions/checkout@v2
Expand All @@ -22,10 +30,14 @@ jobs:
uses: docker/build-push-action@v2
with:
build-args: |
HOST_ARCH=${{ matrix.host-arch }}
TARGET_TRIPLE=${{ matrix.target-triple }}
PKG_FETCH_OPTION_a=${{ matrix.target-arch }}
PKG_FETCH_OPTION_n=node${{ matrix.target-node }}
PKG_FETCH_OPTION_p=alpine
context: .
file: ./Dockerfile.alpine
platforms: linux/amd64
outputs: type=tar,dest=../out.tar

- name: Extract binaries from Docker image
Expand All @@ -40,5 +52,5 @@ jobs:
- uses: actions/upload-artifact@v2
if: steps.check_file.outputs.EXISTS == 'true'
with:
name: node${{ matrix.target-node }}-alpine-x64
name: node${{ matrix.target-node }}-alpine-${{ matrix.target-arch }}
path: root/pkg-fetch/dist/*
44 changes: 43 additions & 1 deletion .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:

jobs:
linux:
linux-x64:
runs-on: ubuntu-20.04

strategy:
Expand All @@ -25,6 +25,7 @@ jobs:
PKG_FETCH_OPTION_n=node${{ matrix.target-node }}
context: .
file: ./Dockerfile.linux
platforms: linux/amd64
outputs: type=tar,dest=../out.tar

- name: Extract binaries from Docker image
Expand All @@ -41,3 +42,44 @@ jobs:
with:
name: node${{ matrix.target-node }}-linux-x64
path: root/pkg-fetch/dist/*

linux-arm64:
runs-on: ubuntu-20.04

strategy:
fail-fast: false
matrix:
target-node: [14, 16, 18, 19]

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=aarch64
PKG_FETCH_OPTION_a=arm64
PKG_FETCH_OPTION_n=node${{ matrix.target-node }}
context: .
file: ./Dockerfile.linuxcross
platforms: linux/amd64
outputs: type=tar,dest=../out.tar

- name: Extract binaries from Docker image
run: |
tar xvf ../out.tar root/pkg-fetch/dist
- name: Check if binary is compiled
id: check_file
run: |
(test -f root/pkg-fetch/dist/*.sha256sum && echo ::set-output name=EXISTS::true) || echo ::set-output name=EXISTS::false
- uses: actions/upload-artifact@v2
if: steps.check_file.outputs.EXISTS == 'true'
with:
name: node${{ matrix.target-node }}-linux-arm64
path: root/pkg-fetch/dist/*
17 changes: 16 additions & 1 deletion .github/workflows/build-linuxstatic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ jobs:
fail-fast: false
matrix:
target-node: [14, 16, 18, 19]
target-arch: [x64, arm64, armv7]
include:
- target-arch: x64
target-triple: x86_64-linux-musl
host-arch: x86_64
- target-arch: arm64
target-triple: aarch64-linux-musl
host-arch: x86_64
- target-arch: armv7
target-triple: armv7l-linux-musleabihf
host-arch: i686

steps:
- uses: actions/checkout@v2
Expand All @@ -22,10 +33,14 @@ jobs:
uses: docker/build-push-action@v2
with:
build-args: |
HOST_ARCH=${{ matrix.host-arch }}
TARGET_TRIPLE=${{ matrix.target-triple }}
PKG_FETCH_OPTION_a=${{ matrix.target-arch }}
PKG_FETCH_OPTION_n=node${{ matrix.target-node }}
PKG_FETCH_OPTION_p=linuxstatic
context: .
file: ./Dockerfile.alpine
platforms: linux/amd64
outputs: type=tar,dest=../out.tar

- name: Extract binaries from Docker image
Expand All @@ -40,5 +55,5 @@ jobs:
- uses: actions/upload-artifact@v2
if: steps.check_file.outputs.EXISTS == 'true'
with:
name: node${{ matrix.target-node }}-linuxstatic-x64
name: node${{ matrix.target-node }}-linuxstatic-${{ matrix.target-arch }}
path: root/pkg-fetch/dist/*
26 changes: 22 additions & 4 deletions Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -1,21 +1,39 @@
FROM alpine
ARG HOST_ARCH=x86_64
ARG TARGET_TRIPLE=aarch64-linux-musl

FROM muslcc/$HOST_ARCH:$TARGET_TRIPLE

ARG PKG_FETCH_OPTION_a
ARG PKG_FETCH_OPTION_n
ARG PKG_FETCH_OPTION_p

USER root:root

WORKDIR /root/pkg-fetch/

RUN apk add --no-cache build-base linux-headers npm pythonispython3 python3 yarn
RUN apk add --no-cache build-base git linux-headers npm pythonispython3 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 LDFLAGS=-Wl,-no-pie
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 --node-range $PKG_FETCH_OPTION_n --platform $PKG_FETCH_OPTION_p --output dist
RUN yarn start --arch $PKG_FETCH_OPTION_a --node-range $PKG_FETCH_OPTION_n --platform $PKG_FETCH_OPTION_p --output dist
Loading

0 comments on commit d1737e2

Please sign in to comment.