samizdatco / skia-canvas

A GPU-accelerated 2D graphics environment for Node.js
MIT License
1.7k stars 66 forks source link

Dependency not found on Google Cloud's Linux #101

Closed Javarome closed 2 years ago

Javarome commented 2 years ago

Recently building on Google Cloud started to fail because of this:

Error: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by /layers/google.nodejs.yarn/yarn_modules/node_modules/skia-canvas/lib/v6/index.node)
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1189:18)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/layers/google.nodejs.yarn/yarn_modules/node_modules/skia-canvas/lib/index.js:23:29)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Object.require.extensions.<computed> [as .js] (/layers/google.nodejs.yarn/yarn_modules/node_modules/ts-node/src/index.ts:1587:43)
    at Module.load (node:internal/modules/cjs/loader:981:32) {

Required is:

"engines": {
   "node": "= 16.x"
 }

and Google Build install Node v16.15.0. Also tried "16.x.x, 14.x, but same error using skia-canvas 0.29 or 0.30.

I'll be happy to provide any other info or attempts workarounds.

ImTheDeveloper commented 2 years ago

Same issue for me on node:14 docker image.

I've had to switch over to slim temporariliy:

FROM node:slim
RUN apt-get update && apt-get install -y -q --no-install-recommends libfontconfig1
samizdatco commented 2 years ago

I wasn't able to get the most recent version of Skia to build on Debian Stretch anymore since it lacks the string_view header (among other recent C++isms that Skia depends on). The solution when using node 14 on docker is to use the node:14-buster image (which has glibc 2.31) instead of the stretch-based node:14 (which is still on 2.24).

As for Google Cloud, I don't know much about it but it seems like the error you're running into is a common one. Are you able to provide your own image to run on instead of using the default environment?

Javarome commented 2 years ago

We workarounded it by indeed using our own docker image, using a Dockerfile like:

# Use the base App Engine Docker image, based on Ubuntu 20.0.4.
FROM ubuntu:20.04

# Install updates and dependencies
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update -y && \
    apt-get install --no-install-recommends -y -q \
      apt-transport-https \
      build-essential \
      ca-certificates \
      curl \
      git \
      imagemagick \
      libkrb5-dev \
      netbase \
      gnupg \
      libfontconfig1 \
      python && \
    apt-get upgrade -y && \
    apt-get clean && \
    rm /var/lib/apt/lists/*_*

# Install node & yarn
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - && \
    curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | tee /usr/share/keyrings/yarnkey.gpg >/dev/null && \
    echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | tee /etc/apt/sources.list.d/yarn.list && \
    apt-get update && apt-get install -y nodejs yarn

# Copy application code.
COPY xxx /app/xxx
COPY yarn.lock /app/

WORKDIR /app

# Install packages
RUN yarn server:build

# Set common env vars
ENV NODE_ENV production
ENV PORT 8080

# start
CMD ["yarn", "start"]

and in our gcloud yaml file, switching from:

runtime: nodejs16
instance_class: F4_1G

to

runtime: custom
env: flex