Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add libc.js to detect linux compiler and add Linux Dockerfile to manage compilation #13

Merged
merged 1 commit into from
Aug 8, 2024
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
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
Loading