Skip to content

Alpine Linux platform support #148

@PaulWieland

Description

@PaulWieland

I'm trying to deploy noderfc under Alpine Linux (specifically node-red docker), but it seems like I might be having issues with ldconfig.

My dockerfile builds, but when my program runs I get the following error:
Error: Error relocating /usr/local/sap/nwrfcsdk/lib/libsapnwrfc.so: __strdup: symbol not found

This is a really similar error as this one, so I am assuming this is an ldconfig problem. However I'm learning that under alpine ldconfig is somehow different from other mainstream linux distros.

I read that under alpine linux LD_LIBRARY_PATH=/usr/local/sap/nwrfcsdk/lib should accomplish the same as loading the /etc/ld.so.conf.d/nwrfcsdk.conf with ldconfig as you would do in other distros, but clearly something isn't working.

Any ideas?

Here is my dockerfile (scroll to #### SAP RFC Stuff, the rest is standard node-red dockerfile).

P.S. There is a curl command to pull the nwrfcsdk.zip file from a local server since I do not think SAP hosts this file for public download - if I'm wrong about that please let me know so I can make a dockerfile that will work for everyone.

ARG ARCH=amd64
ARG NODE_VERSION=10
ARG OS=alpine

#### Stage BASE ########################################################################################################
FROM ${ARCH}/node:${NODE_VERSION}-${OS} AS base

# Copy scripts
COPY scripts/*.sh /tmp/

# Install tools, create Node-RED app and data dir, add user and set rights
RUN set -ex && \
    apk add --no-cache \
        bash \
        tzdata \
        iputils \
        curl \
        nano \
        git \
        openssl \
        openssh-client && \
    mkdir -p /usr/src/node-red /data && \
    deluser --remove-home node && \
    adduser -h /usr/src/node-red -D -H node-red -u 1000 && \
    chown -R node-red:root /data && chmod -R g+rwX /data && \ 
    chown -R node-red:root /usr/src/node-red && chmod -R g+rwX /usr/src/node-red
    # chown -R node-red:node-red /data && \
    # chown -R node-red:node-red /usr/src/node-red

# Set work directory
WORKDIR /usr/src/node-red

# package.json contains Node-RED NPM module and node dependencies
COPY package.json .

#### Stage BUILD #######################################################################################################
FROM base AS build

# Install Build tools
RUN apk add --no-cache --virtual buildtools build-base linux-headers udev python && \
    npm install --unsafe-perm --no-update-notifier --only=production && \
    /tmp/remove_native_gpio.sh && \
    cp -R node_modules prod_node_modules

#### Stage RELEASE #####################################################################################################
FROM base AS RELEASE
ARG BUILD_DATE
ARG BUILD_VERSION
ARG BUILD_REF
ARG NODE_RED_VERSION
ARG ARCH
ARG TAG_SUFFIX=default

LABEL org.label-schema.build-date=${BUILD_DATE} \
    org.label-schema.docker.dockerfile=".docker/Dockerfile.alpine" \
    org.label-schema.license="Apache-2.0" \
    org.label-schema.name="Node-RED" \
    org.label-schema.version=${BUILD_VERSION} \
    org.label-schema.description="Low-code programming for event-driven applications." \
    org.label-schema.url="https://nodered.org" \
    org.label-schema.vcs-ref=${BUILD_REF} \
    org.label-schema.vcs-type="Git" \
    org.label-schema.vcs-url="https://github.com/node-red/node-red-docker" \
    org.label-schema.arch=${ARCH} \
    authors="Dave Conway-Jones, Nick O'Leary, James Thomas, Raymond Mouthaan"

COPY --from=build /usr/src/node-red/prod_node_modules ./node_modules

# Chown, install devtools & Clean up
RUN chown -R node-red:root /usr/src/node-red && \
    /tmp/install_devtools.sh && \
    rm -r /tmp/*

USER node-red

# Env variables
ENV NODE_RED_VERSION=$NODE_RED_VERSION \
    NODE_PATH=/usr/src/node-red/node_modules:/data/node_modules \
    FLOWS=flows.json

# ENV NODE_RED_ENABLE_SAFE_MODE=true    # Uncomment to enable safe start mode (flows not running)
# ENV NODE_RED_ENABLE_PROJECTS=true     # Uncomment to enable projects option

#### SAP RFC Stuff
# Install SAP RFC per these instructions
# http://sap.github.io/node-rfc/install.html#sap-nw-rfc-library-installation

USER root
RUN mkdir -p /usr/local/sap/nwrfcsdk

ENV SAPNWRFC_HOME /usr/local/sap/nwrfcsdk
WORKDIR ${SAPNWRFC_HOME}

RUN curl -O http://some-local-host.net/saprfc/nwrfc750P_4-70002752.zip
RUN unzip nwrfc750P_4-70002752.zip
RUN mv nwrfcsdk/* ./
RUN rmdir nwrfcsdk
RUN rm nwrfc750P_4-70002752.zip

ENV LD_LIBRARY_PATH /usr/local/sap/nwrfcsdk/lib

RUN apk add cmake
RUN apk add libuuid

USER node-red
ENV SAPNWRFC_HOME /usr/local/sap/nwrfcsdk
ENV LD_LIBRARY_PATH /usr/local/sap/nwrfcsdk/lib

WORKDIR /data
RUN npm install node-rfc
RUN npm install node-red-contrib-saprfc

### END SAP RFC Stuff



WORKDIR /usr/src/node-red

# User configuration directory volume
VOLUME ["/data"]

# Expose the listening port of node-red
EXPOSE 1880

# Add a healthcheck (default every 30 secs)
# HEALTHCHECK CMD curl http://localhost:1880/ || exit 1

ENTRYPOINT ["npm", "start", "--cache", "/data/.npm", "--", "--userDir", "/data"]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions