Skip to content

Commit

Permalink
Basic Docker support
Browse files Browse the repository at this point in the history
  • Loading branch information
jdconley committed Mar 30, 2017
1 parent 8f21d2e commit 55f0421
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 12 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
test
LICENSE
Procfile
README.md
npm-debug.log
41 changes: 41 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM node:6.10-alpine
MAINTAINER JD Conley <[email protected]>

USER root
ENV HOME=/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

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

# 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 \
&& 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 \
&& rm -rf /var/cache/apk/* \
&& rm -rf $HOME/src \
&& rm -rf $HOME/bin \
&& rm -f $HOME/tsconfig.json \
&& rm -f $HOME/tslint.json

# Open our port and start the app
EXPOSE 3000
USER pwhaas
ENTRYPOINT ["/sbin/tini", "--"]
CMD [ "node", "dist/bin/www" ]
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"clean": "rm -rf dist",
"build": "tsc -p . && cp -r bin views config public dist",
"lint": "tslint --project tslint.json",
"prepublish": "npm run clean && npm run lint && npm run build",
"prep": "npm run clean && npm run lint && npm run build",
"pretest": "npm run lint && npm run build",
"test": "mocha dist/test/*.js"
},
Expand All @@ -39,16 +39,6 @@
],
"license": "MIT",
"dependencies": {
"@types/body-parser": "0.0.33",
"@types/chai": "^3.4.34",
"@types/config": "0.0.30",
"@types/debug": "0.0.29",
"@types/express": "^4.0.33",
"@types/lodash": "^4.14.37",
"@types/mocha": "^2.2.32",
"@types/node": "^6.0.45",
"@types/serve-favicon": "^2.2.28",
"@types/winston": "0.0.28",
"argon2themax": "^1.0.0",
"body-parser": "^1.15.2",
"config": "^1.21.0",
Expand All @@ -59,11 +49,21 @@
"pug": "^2.0.0-beta3",
"serve-favicon": "^2.3.0",
"toobusy-js": "^0.5.1",
"typescript": "^2.0.3",
"winston": "^2.2.0",
"winston-config": "^0.5.0"
},
"devDependencies": {
"typescript": "^2.0.3",
"@types/body-parser": "0.0.33",
"@types/chai": "^3.4.34",
"@types/config": "0.0.30",
"@types/debug": "0.0.29",
"@types/express": "^4.0.33",
"@types/lodash": "^4.14.37",
"@types/mocha": "^2.2.32",
"@types/node": "^6.0.45",
"@types/serve-favicon": "^2.2.28",
"@types/winston": "0.0.28",
"tslint": "^3.15.1",
"chai": "^3.5.0",
"mocha": "^3.0.2"
Expand Down

0 comments on commit 55f0421

Please sign in to comment.