Skip to content

Commit

Permalink
Update to latest nodejs LTS. Improve Docker image layers.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdconley committed Jul 13, 2017
1 parent 55f0421 commit f890be0
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,38 +1,36 @@
FROM node:6.10-alpine
FROM node:6.11-alpine
MAINTAINER JD Conley <[email protected]>

USER root
ENV HOME=/home/pwhaas
ENV SERVICE_ROOT=/home/pwhaas

# Dependencies for building native components, and our user
# tini is used for proper node signal handling
RUN apk add --update --virtual .build-deps build-base python \
&& apk add --update tini \
&& adduser -u 1001 -D -h $HOME -s /bin/false pwhaas
&& adduser -u 1001 -D -h $SERVICE_ROOT -s /bin/false pwhaas

# Put everything in the home dir and give our user ownership
COPY . $HOME
RUN chown -R pwhaas:pwhaas $HOME/*
WORKDIR $SERVICE_ROOT
COPY package.json package.json

RUN npm install

COPY . $SERVICE_ROOT

# Build the app
# Temporarily pull in the dev dependencies to do the typescript build
USER pwhaas
WORKDIR $HOME
RUN npm install \
&& npm run prep \
&& npm run build \
&& rm -rf node-modules \
RUN npm run prep \
&& rm -rf node_modules \
&& npm install --production \
&& npm cache clean

# Clean up the sources and build artifacts that aren't needed at runtime
USER root
RUN apk del .build-deps \
&& npm cache clean \
&& apk del .build-deps \
&& rm -rf /var/cache/apk/* \
&& rm -rf $HOME/src \
&& rm -rf $HOME/bin \
&& rm -f $HOME/tsconfig.json \
&& rm -f $HOME/tslint.json
&& rm -rf $SERVICE_ROOT/src \
&& rm -rf $SERVICE_ROOT/bin \
&& rm -f $SERVICE_ROOT/tsconfig.json \
&& rm -f $SERVICE_ROOT/tslint.json \
&& chown -R pwhaas:pwhaas $SERVICE_ROOT

# Open our port and start the app
EXPOSE 3000
Expand Down

0 comments on commit f890be0

Please sign in to comment.