Skip to content

Instantly share code, notes, and snippets.

@redecs
Created November 22, 2019 11:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save redecs/fa50b3d7f5ab44740af81c69856e0c9b to your computer and use it in GitHub Desktop.
Save redecs/fa50b3d7f5ab44740af81c69856e0c9b to your computer and use it in GitHub Desktop.
Docker entrypoint example for node.js
#!/bin/sh
NODE_ENV=${NODE_ENV:-production}
set -eux
if [ "$NODE_ENV" != 'production' ]; then
#yarn install --pure-lockfile
#npm install
# see https://docs.npmjs.com/cli/ci
npm ci
fi
exec "$@"
FROM node:${NODE_VERSION}-alpine
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
#COPY package.json yarn.lock ./
COPY package*.json ./
#RUN yarn install --pure-lockfile
RUN npm ci
COPY . ./
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint
RUN chmod +x /usr/local/bin/docker-entrypoint
ENTRYPOINT ["docker-entrypoint"]
#CMD ["yarn", "start"]
CMD ["npm", "start"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment