Skip to content

Commit

Permalink
Merge pull request #13 from MyUnisoft/linuxmusl
Browse files Browse the repository at this point in the history
chore: add libc.js to detect linux compiler and add Linux Dockerfile to manage compilation
  • Loading branch information
Dafyh authored Aug 8, 2024
2 parents 8d7d215 + 9dc0d09 commit 2ba3abb
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 2 deletions.
21 changes: 20 additions & 1 deletion .github/workflows/build-node-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
types: [opened, reopened, synchronize]
paths:
- 'src/lib.cc'
- '.github/workflows/build-node-artifacts.yml'

jobs:
build:
Expand Down Expand Up @@ -35,7 +36,24 @@ jobs:
- name: Create a folder for the tarball
run: mkdir -p release/${{ matrix.PLATFORM }}/lib

- name: Configure and Build projects
- name: Configure and Build projects (Linux)
if: contains(matrix.os, 'ubuntu')
run: |
# Build image
docker build -t ${{ matrix.PLATFORM }} . -f ./npm/${{ matrix.PLATFORM }}/Dockerfile
# Run container
docker run --name ${{ matrix.PLATFORM }} ${{ matrix.PLATFORM }}
- name: Copy .node file from docker container (Linux)
if: contains(matrix.os, 'ubuntu')
env:
source: ${{ matrix.PLATFORM }}:/heif-converter/src/build/Release
destination: ./release/${{ matrix.PLATFORM }}/lib
run: docker cp $source/converter.node $destination/converter.${{ matrix.PLATFORM }}.node

- name: Configure and Build projects (Windows & OSX)
if: "!contains(matrix.os, 'ubuntu')"
run: |
# Build project
npm install --omit-optional
Expand All @@ -56,6 +74,7 @@ jobs:
cp platform/${{ matrix.PLATFORM }}/bin/libpng16.dll ./release/${{ matrix.PLATFORM }}/lib/libpng16.dll
- name: Run tests
if: "!contains(matrix.os, 'ubuntu')"
run: npm run test

- name: Create tarball of the release folder
Expand Down
4 changes: 4 additions & 0 deletions libc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Import Third-Party Dependencies
const { familySync, MUSL } = require("detect-libc");

console.log(familySync() === MUSL ? "musl" : "");
20 changes: 20 additions & 0 deletions npm/linux-x64/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM node:18-bullseye
LABEL maintainer="Nicolas Marteau <[email protected]>"
USER root

RUN apt-get update && \
apt-get install -y \
build-essential \
python3 \
python3-setuptools \
python3-mako \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /heif-converter

COPY . .

RUN npm install
RUN npm run configure
RUN npm run build
RUN npm run test
34 changes: 34 additions & 0 deletions npm/linuxmusl-x64/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM node:18-alpine
LABEL maintainer="Nicolas Marteau <[email protected]>"

RUN apk --no-cache add \
g++ \
gcc \
git \
zip \
tar \
wget \
nasm \
cmake \
make \
unzip \
bison \
libgcc \
libstdc++ \
gettext-dev \
glib-dev \
bash \
py3-setuptools \
linux-headers \
build-base \
curl && \
ln -sf python3 /usr/bin/python

WORKDIR /heif-converter

COPY . .

RUN npm install
RUN npm run configure
RUN npm run build
RUN npm run test
2 changes: 1 addition & 1 deletion src/binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
[
'"<!(echo $VCPKG_LIB_ROOT)" == ""',
{
"VCPKG_LIB_ROOT%": "<(module_root_dir)/../platform/linux-x64"
"VCPKG_LIB_ROOT%": "<(module_root_dir)/../platform/linux<!(node ../libc.js)-x64"
}
]
]
Expand Down

0 comments on commit 2ba3abb

Please sign in to comment.