Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Properly cross-compile for Linux arm64 #352

Merged
merged 3 commits into from
Feb 14, 2021
Merged
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
22 changes: 11 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,21 @@ jobs:
npm run prebuild-electron
name: Prebuild (x64)

- run: npm run prebuild-electron-arm64
if: ${{ matrix.os != 'macos-latest' }}
name: Prebuild for Electron (ARM64)

- run: |
docker build -t node-keytar/i386 docker/i386
docker run --rm -v ${PWD}:/project node-keytar/i386 /bin/bash -c "cd /project && npm run prebuild-node-ia32 && npm run prebuild-electron-ia32"
if: ${{ matrix.os == 'ubuntu-16.04' }}
name: Prebuild (x86)

- run: |
npm run prebuild-electron-arm64
npm run prebuild-node-ia32
npm run prebuild-electron-ia32
if: ${{ matrix.os == 'windows-latest' }}
name: Prebuild (x86)
name: Prebuild (Windows x86 + ARM64)

- run: |
mkdir -p prebuilds && chmod 777 prebuilds
docker build -t node-keytar/i386 docker/i386
docker run --rm -v ${PWD}:/project node-keytar/i386 /bin/bash -c "cd /project && npm run prebuild-node-ia32 && npm run prebuild-electron-ia32 && rm -rf build"
docker build -t node-keytar/arm64-cross-compile docker/arm64-cross-compile
docker run --rm -v ${PWD}:/project node-keytar/arm64-cross-compile /bin/bash -c "cd /project && npm run prebuild-electron-arm64"
if: ${{ matrix.os == 'ubuntu-16.04' }}
name: Prebuild (Linux x86 + ARM64)

- run: |
ls prebuilds/
Expand Down
9 changes: 8 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,12 @@ script:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then npm test; fi
- npm run prebuild-node
- npm run prebuild-electron
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker build -t node-keytar/i386 docker/i386 && docker run --rm -v ${PWD}:/project node-keytar/i386 /bin/bash -c "cd /project && npm run prebuild-node-ia32 && npm run prebuild-electron-ia32 && npm run prebuild-electron-arm64"; fi
- |
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
mkdir -p prebuilds && chmod 777 prebuilds
docker build -t node-keytar/i386 docker/i386
Copy link
Contributor

Choose a reason for hiding this comment

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

Why build it every time, and not just publish it on docker hub?

Copy link
Contributor

@shiftkey shiftkey Feb 14, 2021

Choose a reason for hiding this comment

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

Having done this on other OSS projects, unless there's a need for this specific setup from the community I prefer having a fast feedback loop by using the same Dockerfile from the repository.

If this were a bigger project, with a more active CI, I'd re-evaluate and maybe get this publishing to Docker Hub.

docker run --rm -v ${PWD}:/project node-keytar/i386 /bin/bash -c "cd /project && npm run prebuild-node-ia32 && npm run prebuild-electron-ia32 && rm -rf build"
docker build -t node-keytar/arm64-cross-compile docker/arm64-cross-compile
docker run --rm -v ${PWD}:/project node-keytar/arm64-cross-compile /bin/bash -c "cd /project && npm run prebuild-electron-arm64"
fi
- if [[ -n "$TRAVIS_TAG" ]]; then npm run upload; fi
29 changes: 29 additions & 0 deletions docker/arm64-cross-compile/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM debian:buster

RUN dpkg --add-architecture arm64
RUN apt-get update && apt-get install -y --no-install-recommends \
crossbuild-essential-arm64 \
python \
git \
pkg-config \
fakeroot \
rpm \
ca-certificates \
libx11-dev:arm64 \
libx11-xcb-dev:arm64 \
libxkbfile-dev:arm64 \
libsecret-1-dev:arm64 \
curl

ENV AS=/usr/bin/aarch64-linux-gnu-as \
STRIP=/usr/bin/aarch64-linux-gnu-strip \
AR=/usr/bin/aarch64-linux-gnu-ar \
CC=/usr/bin/aarch64-linux-gnu-gcc \
CPP=/usr/bin/aarch64-linux-gnu-cpp \
CXX=/usr/bin/aarch64-linux-gnu-g++ \
LD=/usr/bin/aarch64-linux-gnu-ld \
FC=/usr/bin/aarch64-linux-gnu-gfortran \
PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig

RUN curl -sL https://deb.nodesource.com/setup_15.x | bash -
RUN apt-get install -y nodejs