-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to latest nodejs LTS. Improve Docker image layers.
- Loading branch information
Showing
1 changed file
with
18 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|