question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Docker node:8.5.0-alpine

See original GitHub issue

Hi…

I have 2 Dockerfiles very similar in my project (you can see below) Using node:8.5.0 works fine

But using node:8.5.0-alpine I’ve got this error: Segmentation fault

I tried this: npm i --silent --build-from-source --progress=false --production in alpine… unsuccessfully 😞

I discovered that:

Alpine uses musl instead of glibc, and therefore binaries built with gcc for glibc will be binary incompatible, as far as I’m aware.

Is there anyway for the levelup to work on the node:alpine?

Tks!

node                8.5.0-alpine                 67MB
node                8.5.0                        673MB

node:8.5.0 (Debian)

FROM node:8.5.0

# cria o usuário tex
RUN useradd -ms /bin/bash tex

# seta as variáveis de ambiente
ENV HOME=/home/tex
ENV APP=$HOME/consulta-cep

# cria a pasta do app
RUN mkdir $APP

# copia o package.json e ajusta as permissões
COPY package.json $APP/.
RUN chown -R tex:tex $HOME

# troca de usuário (tex) e instala os pacotes
USER tex
WORKDIR $APP
RUN npm i --silent --build-from-source --progress=false --production

# troca de usuário (root), copia os arquivos do app, ajusta as permissões e deleta o usuário node
USER root
COPY . $APP
RUN chown -R tex:tex $APP
RUN userdel -r node

# troca de usuário (tex), libera a porta 3000 e roda o comando
USER tex
EXPOSE 3000
CMD ["npm", "start"]

node:8.5.0-alpine

FROM node:8.5.0-alpine

# instala o bash e cria o usuário tex
RUN apk add --no-cache bash
RUN addgroup tex && adduser -s /bin/bash -D -G tex tex

# seta as variáveis de ambiente
ENV HOME=/home/tex
ENV APP=$HOME/consulta-cep

# cria a pasta do app
RUN mkdir $APP

# copia o package.json e ajusta as permissões
COPY package.json $APP/.
RUN chown -R tex:tex $HOME

# troca de usuário (tex) e instala os pacotes
USER tex
WORKDIR $APP
RUN npm i --silent --progress=false --production

# troca de usuário (root), copia os arquivos do app, ajusta as permissões e deleta o usuário node
USER root
COPY . $APP
RUN chown -R tex:tex $APP
RUN deluser --remove-home node

# troca de usuário (tex), libera a porta 3000 e roda o comando
USER tex
EXPOSE 3000
CMD ["npm", "start"]

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
jstabenowcommented, Sep 13, 2017

@ralphtheninja you are right. for building from source we need additional packages:

FROM node:8.4-alpine
RUN apk add --update python make g++ && \
    npm install -g standard tape faucet levelup@1.3.9
WORKDIR /usr/local/lib/node_modules/levelup
RUN npm install --build-from-source && \
    standard && \
    tape test/*-test.js | faucet

And the result:

# tests 137
# pass  137
✓ ok

Thanks!

2reactions
lagdencommented, Sep 13, 2017

@jstabenow and @ralphtheninja

Very thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

node - Official Image | Docker Hub
Node.js is a JavaScript-based platform for server-side and networking applications.
Read more >
Error with Node:8-alpine docker image on AWS using an M5 ...
Problem: Node 8 alpine image does not appear to work on AWS m5 instances. Command: docker container run -it node:8-alpine /bin/sh -c 'npm ......
Read more >
Running Node.js in Docker for local development - nystudio107
You don't need to know Docker to benefit from running local dev Node.js buildchains & apps inside of Docker containers.
Read more >
How to Deploy a Node.js (Express.js) App with Docker on ...
Docker Hub allows developers to host containerized applications for easy deployment to any Docker environment. Once your container is hosted on Docker Hub,...
Read more >
Multi-stage Docker builds for ASP.NET Core 5
NET project, you get a multi-stage Dockerfile for free (well, as long as you select that option). But, I want to use vanilla...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found