Skip to content

Commit 5f6ee5f

Browse files
committed
build-system updates
- added support for arm64 on Alpine (fixes samizdatco#95) - debian-stretch no longer supports clang through backports, so moved to buster - alpine builds now just pull gn & ninja from the edge distro, leaving libstdc++ compatible with what's on the node:alpine docker image (fixes samizdatco#97) - the glibc & musl images are now multiplatform, so if arm-based runners are ever a thing they'll be ready… - self-hosted musl/arm64 builds can’t use js-based workflow actions (as of june 2022) so the arm64 build is all shell for now
1 parent 735e847 commit 5f6ee5f

File tree

9 files changed

+186
-110
lines changed

9 files changed

+186
-110
lines changed

.github/workflows/arch.yml

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
workflow_dispatch:
44

55
jobs:
6-
intel:
6+
server:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
@@ -13,30 +13,29 @@ jobs:
1313
- name: Checkout
1414
uses: actions/checkout@v2
1515

16+
- name: Set up QEMU
17+
uses: docker/setup-qemu-action@v2
18+
19+
- name: Set up Docker Buildx
20+
uses: docker/setup-buildx-action@v2
21+
1622
- name: Login to GitHub Container Registry
1723
uses: docker/login-action@v1
1824
with:
1925
registry: ghcr.io
2026
username: ${{ github.repository_owner }}
2127
password: ${{ secrets.CR_PAT }}
2228

23-
- name: Build and Push Docker Image
24-
uses: docker/build-push-action@v2
29+
- name: Build and push
30+
uses: docker/build-push-action@v3
2531
with:
2632
tags: ghcr.io/${{ github.repository }}-${{ matrix.libc }}:latest
2733
context: arch/${{ matrix.libc }}
34+
platforms: linux/amd64,linux/arm64
2835
push: true
2936

30-
acorn:
31-
runs-on:
32-
- self-hosted
33-
- linux
34-
- ${{ matrix.runner }}
35-
36-
strategy:
37-
fail-fast: false
38-
matrix:
39-
runner: [ARM, ARM64]
37+
pi:
38+
runs-on: [self-hosted, linux, ARM]
4039

4140
steps:
4241
- name: Checkout
@@ -49,16 +48,11 @@ jobs:
4948
username: ${{ github.repository_owner }}
5049
password: ${{ secrets.CR_PAT }}
5150

52-
- id: cpu
53-
uses: ASzc/change-string-case-action@v1
54-
with:
55-
string: ${{ matrix.runner }}
56-
5751
- name: Build and Push Docker Image
5852
run: |
5953
cd ${{ env.context }}
6054
docker build . -t ${{ env.tag }}
6155
docker push ${{ env.tag }}
6256
env:
63-
context: arch/${{ steps.cpu.outputs.lowercase }}
64-
tag: ghcr.io/${{ github.repository }}-${{ steps.cpu.outputs.lowercase }}:latest
57+
context: arch/arm
58+
tag: ghcr.io/${{ github.repository }}-arm:latest

.github/workflows/build.yml

Lines changed: 97 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,115 @@ jobs:
1717
image: ${{ format('ghcr.io/{0}-{1}:latest', github.repository, matrix.libc) }}
1818

1919
steps:
20-
- name: Checkout repository
20+
- name: Install rust
21+
run: |
22+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
23+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
24+
25+
- name: Checkout skia-canvas
2126
uses: actions/checkout@v2
2227
with:
2328
path: skia-canvas
2429

30+
- name: Determine current upstream version
31+
id: rust-skia
32+
run: |
33+
export TAG=$(awk '/\[dependencies.skia-safe\]/{getline; print}' skia-canvas/Cargo.toml | egrep -o '[0-9\.]+')
34+
echo "::set-output name=VERSION::$TAG"
35+
36+
- name: Checkout rust-skia
37+
if: ${{ matrix.libc == 'musl' }}
38+
uses: actions/checkout@v2
39+
with:
40+
repository: rust-skia/rust-skia
41+
ref: ${{ steps.rust-skia.outputs.VERSION }}
42+
submodules: true
43+
path: rust-skia
44+
45+
- name: Patch build files
46+
if: ${{ matrix.libc == 'musl' }}
47+
run: |
48+
patch -p0 < /code/alpine-build.patch
49+
perl -0777 -pi.bak -e 's/(\[dependencies.skia-safe\]\n)version.*/$1path = "..\/rust-skia\/skia-safe"/m' skia-canvas/Cargo.toml
50+
51+
- name: Build module
52+
run: |
53+
cd skia-canvas
54+
npm ci --ignore-scripts
55+
npm run build -- --release --features skia-safe/embed-freetype
56+
57+
- name: Package module
58+
run: |
59+
cd skia-canvas
60+
npm test && npm run package
61+
62+
- name: Upload to S3
63+
env:
64+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
65+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
66+
run: |
67+
cd skia-canvas
68+
npm run upload
69+
70+
71+
linux-arm64:
72+
runs-on:
73+
- self-hosted
74+
- linux
75+
- ARM64
76+
strategy:
77+
fail-fast: false
78+
matrix:
79+
libc: [glibc, musl]
80+
81+
container:
82+
image: ${{ format('ghcr.io/{0}-{1}:latest', github.repository, matrix.libc) }}
83+
options: --user 1000:1000
84+
85+
steps:
86+
- name: Prepare workspace
87+
run: |
88+
rm -rf "$GITHUB_WORKSPACE"
89+
mkdir -p "$GITHUB_WORKSPACE"
90+
2591
- name: Install rust
2692
run: |
2793
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
2894
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
2995
30-
- name: Checkout rust-skia
96+
- name: Checkout skia-canvas
3197
id: rust-skia
98+
env:
99+
SERVER: ${{ github.server_url }}
100+
REPO: ${{ github.repository }}
32101
run: |
33-
export TAG=$(awk '/skia-safe/{getline; print}' skia-canvas/Cargo.toml | egrep -o '[0-9\.]+')
34-
git clone --depth 1 --branch $TAG https://github.com/rust-skia/rust-skia.git
102+
git clone --depth 1 ${SERVER}/${REPO} skia-canvas
103+
export TAG=$(awk '/\[dependencies.skia-safe\]/{getline; print}' skia-canvas/Cargo.toml | egrep -o '[0-9\.]+')
104+
perl -0777 -pi.bak -e 's/(\[dependencies.skia-safe\]\n)version.*/$1path = "..\/rust-skia\/skia-safe"/m' skia-canvas/Cargo.toml
105+
echo "::set-output name=VERSION::$TAG"
106+
107+
- name: Checkout rust-skia
108+
run: |
109+
git clone --depth 1 --branch ${{ steps.rust-skia.outputs.VERSION }} https://github.com/rust-skia/rust-skia.git
35110
cd rust-skia
36111
git submodule update --init --depth 1 skia-bindings/skia
37112
git submodule update --init --depth 1 skia-bindings/depot_tools
38113
39-
- name: Patch build files
114+
- name: Apply patches
40115
if: ${{ matrix.libc == 'musl' }}
41116
run: |
42117
patch -p0 < /code/alpine-build.patch
118+
119+
- name: Use system GN
120+
if: ${{ matrix.libc == 'musl' }}
121+
run: |
43122
echo "#!/bin/true" > rust-skia/skia-bindings/skia/bin/fetch-gn
44-
perl -0777 -pi.bak -e 's/(\[dependencies.skia-safe\]\n)version.*/$1path = "..\/rust-skia\/skia-safe"/m' skia-canvas/Cargo.toml
45123
46124
- name: Build module
47125
run: |
48126
cd skia-canvas
49-
perl -0777 -pi.bak -e 's/("textlayout")/$1, "embed-freetype"/' Cargo.toml
50127
npm ci --ignore-scripts
51-
npm run build -- --release
128+
npm run build -- --release --features skia-safe/embed-freetype
52129
53130
- name: Package module
54131
run: |
@@ -68,31 +145,26 @@ jobs:
68145
runs-on:
69146
- self-hosted
70147
- linux
71-
- ${{ matrix.runner }}
72-
strategy:
73-
fail-fast: false
74-
matrix:
75-
runner: [ARM, ARM64]
76-
include:
77-
- runner: ARM
78-
container: ${{ format('ghcr.io/{0}-{1}:latest', github.repository, 'arm') }}
79-
- runner: ARM64
80-
container: ${{ format('ghcr.io/{0}-{1}:latest', github.repository, 'arm64') }}
81-
148+
- ARM
82149
container:
83-
image: ${{ matrix.container }}
150+
image: ${{ format('ghcr.io/{0}-{1}:latest', github.repository, 'arm') }}
84151

85152
steps:
86-
- name: Use Node.js
87-
uses: actions/setup-node@v2
88-
with:
89-
node-version: 14
153+
- name: Prepare workspace
154+
run: |
155+
rm -rf "$GITHUB_WORKSPACE"
156+
mkdir -p "$GITHUB_WORKSPACE"
90157
91158
- name: Install rust
92159
run: |
93160
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
94161
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
95162
163+
- name: Use Node.js
164+
uses: actions/setup-node@v2
165+
with:
166+
node-version: 14
167+
96168
- name: Checkout repository
97169
uses: actions/checkout@v2
98170
with:
@@ -117,15 +189,14 @@ jobs:
117189
perl -0777 -pi.bak -e 's/(\[dependencies.skia-safe\]\n)version.*/$1path = "..\/rust-skia\/skia-safe"/m' skia-canvas/Cargo.toml
118190
119191
- name: Use system GN
120-
if: ${{ matrix.runner == 'ARM' }}
121192
run: |
122193
echo "#!/bin/true" > rust-skia/skia-bindings/skia/bin/fetch-gn
123194
124195
- name: Build module
125196
run: |
126197
cd skia-canvas
127198
npm ci --ignore-scripts
128-
npm run build -- --release
199+
npm run build -- --release --features skia-safe/embed-freetype
129200
130201
- name: Package module
131202
run: |

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- Enhacements to the shared **FontLibrary** object:
77
- Added a [`reset()`][FontLibrary.reset] method to FontLibrary which uninstalls any fonts that had been dynamically installed via `FontLibrary.use()`
88
- The [`use()`][FontLibrary.use] method now checks for previously installed fonts with the same family name (or alias) and will replace them with the newly added font
9+
- Added pre-compiled binaries for Alpine Linux on arm64
910

1011
### Bugfixes
1112

@@ -16,6 +17,7 @@
1617
- [`conicCurveTo()`][conicCurveTo] now correctly reflects the canvas's transform state
1718
- The browser-based version of [`loadImage()`][loadImage] now returns a **Promise** that correctly resolves to an **Image** object
1819
- SVG exports no longer have an invisible, canvas-sized `<rect/>` as their first element
20+
- Fixed an incompatibility on Alpine between the version of libstdc++ present on the `node:alpine` docker images and the version used when building the precompiled binaries
1921

2022
### Misc. Improvements
2123
- Upgraded Skia to milestone 101

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Nearly everything you need is statically linked into the library. A notable exce
5252

5353
### Running in Docker
5454

55-
The library is compatible with Linux systems using [glibc](https://www.gnu.org/software/libc/) 2.24 or later as well as Alpine Linux (x64 only) and the [musl](https://musl.libc.org) C library it favors. In both cases, Fontconfig must be installed on the system for `skia-canvas` to operate correctly.
55+
The library is compatible with Linux systems using [glibc](https://www.gnu.org/software/libc/) 2.24 or later as well as Alpine Linux (x64 & arm64) and the [musl](https://musl.libc.org) C library it favors. In both cases, Fontconfig must be installed on the system for `skia-canvas` to operate correctly.
5656

5757
If you are setting up a [Dockerfile](https://nodejs.org/en/docs/guides/nodejs-docker-webapp/) that uses [`node`](https://hub.docker.com/_/node) as its basis, the simplest approach is to set your `FROM` image to one of the (Debian-derived) defaults like `node:16`, `node:14`, `node:12`, `node:bullseye`, `node:buster`, or simply:
5858
```dockerfile
@@ -71,7 +71,6 @@ If you wish to use Alpine as the underlying distribution, you can start with som
7171
```dockerfile
7272
FROM node:alpine
7373
RUN apk update && apk add fontconfig
74-
RUN apk -UvX http://dl-cdn.alpinelinux.org/alpine/edge/main add -u nodejs
7574
```
7675

7776
### Compiling from Source

arch/arm/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ ENV SKIA_GN_COMMAND="/usr/local/bin/gn"
1717
ENV SKIA_NINJA_COMMAND="/usr/bin/ninja"
1818

1919
RUN groupadd -r -g 1000 pi
20-
RUN useradd -r -u 1000 -g pi pi
20+
RUN useradd -r -m -u 1000 -g pi pi
2121
USER pi

arch/arm64/Dockerfile

Lines changed: 0 additions & 12 deletions
This file was deleted.

arch/glibc/Dockerfile

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
FROM node:lts-stretch-slim
1+
FROM node:buster-slim
22

3-
RUN apt-get update && apt-get install -y -q software-properties-common
4-
RUN add-apt-repository "deb http://deb.debian.org/debian stretch-backports main"
5-
RUN apt-get update && apt-get install -y \
6-
curl less build-essential lsb-release wget python2.7 \
7-
libssl-dev libfontconfig-dev git clang-5.0 lld-5.0
3+
RUN apt-get update && \
4+
apt-get install -y -q \
5+
python2 python3 perl git clang lldb lld \
6+
build-essential software-properties-common \
7+
libssl-dev libfontconfig-dev \
8+
ninja-build
89

9-
RUN ln -s /usr/bin/clang++-5.0 /usr/bin/clang++
10-
RUN ln -s /usr/bin/clang-5.0 /usr/bin/clang
11-
RUN ln -s /usr/bin/clang-cpp-5.0 /usr/bin/clang-cpp
12-
RUN ln -s /usr/bin/ld.lld-5.0 /usr/bin/ld.lld
13-
RUN ln -s /usr/bin/lld-5.0 /usr/bin/lld
10+
RUN add-apt-repository "deb http://deb.debian.org/debian buster-backports main" && \
11+
apt-get update && apt-get install -t buster-backports -y -q \
12+
curl
1413

15-
RUN groupadd -r -g 1001 ghuser
16-
RUN useradd -r -u 1001 -g ghuser ghuser
17-
USER ghuser
14+
ENV SKIA_NINJA_COMMAND="/usr/bin/ninja"

arch/musl/Dockerfile

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,20 @@ FROM node:16-alpine
33
ENV RUSTFLAGS="-C target-feature=-crt-static" \
44
CC="clang" \
55
CXX="clang++" \
6-
GN_EXE=gn \
6+
GN_EXE="gn" \
77
SKIA_GN_COMMAND="/usr/bin/gn" \
88
SKIA_NINJA_COMMAND="/usr/bin/ninja"
99

10-
RUN sed -i -e 's/v[[:digit:]]\..*\//edge\//g' /etc/apk/repositories
10+
RUN apk update && apk add --update --no-cache \
11+
bash curl git python3 python2 perl clang llvm g++ build-base \
12+
musl-dev openssl-dev fontconfig-dev fontconfig ttf-dejavu
13+
1114
RUN apk add --update --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing \
12-
bash curl git tar python3 python2 perl clang llvm make gn ninja \
13-
musl-dev build-base fontconfig-dev openssl-dev g++ \
14-
fontconfig ttf-dejavu
15-
RUN apk upgrade
15+
gn ninja
16+
17+
RUN export ASM="/usr/include/c++/10.3.1/aarch64-alpine-linux-musl/asm" && \
18+
mkdir -p ${ASM} && \
19+
touch ${ASM}/hwcap.h
1620

1721
WORKDIR /code
18-
COPY alpine-build.patch .
22+
COPY alpine-build.patch .

0 commit comments

Comments
 (0)