Skip to content

Instantly share code, notes, and snippets.

@marweck
Last active October 16, 2018 22:36
Show Gist options
  • Save marweck/f424f34fc0b58a6f8c14353d18249ea6 to your computer and use it in GitHub Desktop.
Save marweck/f424f34fc0b58a6f8c14353d18249ea6 to your computer and use it in GitHub Desktop.
Docker image for building and running Node app on server
# --- base ---
FROM node:8-alpine AS base
RUN mkdir -p /var/www && mkdir -p /var/log/app
ADD package.json /var/www
COPY . /tmp/
RUN cd /tmp && \
apk add --no-cache make gcc g++ python && \
npm install -g typescript && \
npm install --production --silent && \
npm run build && \
apk del make gcc g++ python
# --- release ---
FROM node:8-alpine AS release
WORKDIR /app
COPY --from=base /tmp/node_modules ./node_modules
COPY --from=base /tmp/dist .
VOLUME /var/log/app
EXPOSE 3000
CMD ["node", "main.js"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment