From f890be04e9037b7e638a355ad47fcfe7b507b326 Mon Sep 17 00:00:00 2001 From: JD Conley Date: Thu, 13 Jul 2017 15:15:44 -0700 Subject: [PATCH] Update to latest nodejs LTS. Improve Docker image layers. --- Dockerfile | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/Dockerfile b/Dockerfile index 27ecb95..ec2f8bb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,38 +1,36 @@ -FROM node:6.10-alpine +FROM node:6.11-alpine MAINTAINER JD Conley 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