Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

178
Visualizações
Is it possible to build nodeJS container based on SCRATCH reference?

My requirement is to optimize and secure base image for nodeJS. I have tried building it on SCRATCH using multistage docker but the final container getting into crashed state.

Looking for a sample docker file working on SCRATCH base.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

It's very much possible to build NodeJS applications on docker scratch image. Commands on the Scratch needs to be thoroughly verified by pointing to right path for node executable, if not it will result in crash as there will be no command line interface on scratch base.

Here is the dockerfile for sample NodeJS todo application and git reference.

FROM siva094/node-scratch-static:1 as buildnode
#########################
#### Source code  ########
########################
FROM alpine/git as codecheckout
WORKDIR /app
RUN git clone https://github.com/siva094/nodejs-todo.git
######################
#### Code Build #####
####################
FROM node:10-alpine as sourcecode
WORKDIR /app
COPY  --from=codecheckout /app/nodejs-todo/ ./
RUN npm install --prod
###################
#### Target APP ###
##################
FROM scratch
COPY --from=buildnode /node/out/Release/node /node
COPY --from=sourcecode /app ./
ENV PATH "$PATH:/node"
EXPOSE 3000
ENTRYPOINT ["/node", "index.js"]

Git Reference - https://github.com/siva094/nodejs-todo

Docker References:

NodeJS fully static build and NodeJS todo app

 docker pull siva094/node-fullystatic
 docker pull siva094/nodejs-scratch-todo

Adding reference for building a static node.

source code URL - github.com/siva094/Dockers/blob/master/Dockerfile

FROM node:latest as builder
RUN apk --no-cache add --virtual native-deps \
  g++ gcc libgcc libstdc++ linux-headers autoconf automake make nasm python git && \
  npm install --quiet node-gyp -g
RUN npm install --quiet node-gyp -g
RUN git clone https://github.com/nodejs/node && \
    cd node && \
    ./configure --fully-static --enable-static && \
    make

FROM scratch
COPY --from=builder /node/out/Release/node /node
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda