“NODEJS Dockerhub” Kode Jawaban

Docker Node Alpine

# Copy and paste to pull this image for the latest 
docker pull node

# more specific use this line
# docker pull node:<version>-alpine 
docker pull node:14.4-alpine3.11
tsboh

NODEJS Dockerhub

############### RECOMMENDED DOCKER IMAGE VERSION ###############
# <node version>-buster (debian 10) -> latest version
# <node version>-stretch (debian 9) -> stable version
# <node version>-alpine3.15 (alpine) -> small size version
################################################################

######################
# START STAGE 1
######################
FROM node:14.19.1-buster as start # change node version with same your app use
USER ${USER}
ENV NODE_OPTIONS=--max_old_space_size=32768
ADD ./package.*json ./
ADD . ./

#######################
# UPGRADE STAGE 2
#######################
FROM start as upgrade
COPY --from=start . ./
RUN apt-get autoremove \ # this command only for debian image version, change command if you use alpine linux image version
  && apt-get autoclean \
  && apt-get update \
  && apt-get upgrade -y \
  && apt-get install build-essential -y

#######################
# FINAL STAGE 3
#######################
FROM upgrade as final
COPY --from=upgrade . ./
RUN rm -rf node_modules \
  && npm cache clean -f \
  && npm config delete proxy \
  delete https-proxy \
  -g delete proxy \
  -g delete https-proxy \
  set fetch-retries 10 \
  set fetch-retry-factor 20 \
  set fetch-retry-mintimeout 6000000 \
  set fetch-retry-maxtimeout 12000000 \
  set cache-min 3600 \
  set strict-ssl false \
  set audit false \
  set unsafe-perm true \
  && npm i -g --unsafe-perm \
  node-gyp -g \
  @xpack-dev-tools/windows-build-tools@latest -g \
  pm2 -g \ # remove this if you not run your app with pm2
  && npm i --verbose --no-audit \
  && npm rebuild bcrypt --build-from-source \ # remove this if you no need
  && npm run build \ # change with your command app
  && npm config ls -l
EXPOSE 3000 # change with your port app
CMD npm run prod # change with your command app
Restu Wahyu Saputra

Jawaban yang mirip dengan “NODEJS Dockerhub”

Pertanyaan yang mirip dengan “NODEJS Dockerhub”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya