Skip to content

Instantly share code, notes, and snippets.

@EnzoMartin
Last active November 10, 2021 08:23
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save EnzoMartin/6b40242e38b6ae232c9d6c990871b454 to your computer and use it in GitHub Desktop.
Save EnzoMartin/6b40242e38b6ae232c9d6c990871b454 to your computer and use it in GitHub Desktop.
Building & using Node Alpine docker image
# Runtime image
# Following https://github.com/nodejs/docker-node/blob/master/docs/BestPractices.md
FROM node:7.7-alpine
# Add tini
RUN apk add --no-cache tini
ENTRYPOINT ["/sbin/tini", "--"]
WORKDIR /usr/src/app/
# Copy built application modules
COPY ./src/ ./node_modules/
# Copy application files
COPY . ./
CMD [ "node", "service/start.js" ]
# Build image
FROM node:7.7-alpine
# Enables colored output in jenkins logs
ENV FORCE_COLOR=true \
TERM=xterm \
CI=true
# Set npm auth token
ARG NPM_TOKEN
RUN echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc \
&& echo "progress=false" >> /root/.npmrc \
&& echo "color=true" >> /root/.npmrc
# Create app directory
WORKDIR /usr/src/app/
# Copy package.json and shrinkwrap if present
COPY *.json ./
# Add packages needed to build native dependencies
RUN apk add --no-cache \
git \
python \
python-dev \
py-pip \
build-base \
libc6-compat \
&& pip install virtualenv
# Install modules
RUN npm install --quiet
# Copy over the application code so we can run lint, tests, etc.
COPY . ./
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment