-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding docker and compose requirements
- Loading branch information
1 parent
81688de
commit 7377f1a
Showing
5 changed files
with
82 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# add git-ignore syntax here of things you don't want copied into docker image | ||
|
||
.git | ||
*Dockerfile* | ||
*docker-compose* | ||
node_modules |
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# if you're doing anything beyond your local machine, please pin this to a specific version at https://hub.docker.com/_/node/ | ||
FROM node:8 | ||
|
||
RUN mkdir -p /opt/app | ||
# set our node environment, either development or production | ||
# defaults to production, compose overrides this to development on build and run | ||
ARG NODE_ENV=production | ||
ENV NODE_ENV $NODE_ENV | ||
|
||
# default to port 80 for node, and 5858 or 9229 for debug | ||
ARG PORT=80 | ||
ENV PORT $PORT | ||
EXPOSE $PORT 5858 9229 | ||
|
||
# check every 30s to ensure this service returns HTTP 200 | ||
HEALTHCHECK CMD curl -fs http://localhost:$PORT/ || exit 1 | ||
|
||
# install dependencies first, in a different location for easier app bind mounting for local development | ||
WORKDIR /opt | ||
COPY package.json package-lock.json* ./ | ||
RUN npm install && npm cache clean --force | ||
ENV PATH /opt/node_modules/.bin:$PATH | ||
|
||
# run bower | ||
ENV BOWER_PATH /opt | ||
COPY ./bower.json . | ||
RUN bower install --allow-root | ||
|
||
# copy in our source code last, as it changes the most | ||
WORKDIR /opt/app | ||
COPY . /opt/app | ||
|
||
# if you want to use npm start instead, then use `docker run --init in production` | ||
# so that signals are passed properly. Note the code in index.js is needed to catch Docker signals | ||
# using node here is still more graceful stopping then npm with --init afaik | ||
# I still can't come up with a good production way to run with npm and graceful shutdown | ||
CMD [ "node", "app.js" ] |
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
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
version: '3.1' | ||
|
||
services: | ||
web: | ||
build: | ||
context: . | ||
args: | ||
- NODE_ENV=development | ||
# you can use legacy debug config or new inspect | ||
# NOTE: if nodemon isn't restarting on changes, you might be on Windows | ||
# which has trouble seeing file changes, so add -L to use legacy polling | ||
# https://github.com/remy/nodemon#application-isnt-restarting | ||
#command: ../node_modules/.bin/nodemon --debug=0.0.0.0:5858 | ||
command: ../node_modules/.bin/nodemon --inspect=0.0.0.0:9229 | ||
ports: | ||
- "80:80" | ||
- "5858:5858" | ||
- "9229:9229" | ||
volumes: | ||
- .:/opt/app | ||
# this is a workaround to prevent host node_modules from accidently getting mounted in container | ||
# in case you want to use node/npm both outside container for test/lint etc. and also inside container | ||
# this will overwrite the default node_modules dir in container so it won't conflict with our | ||
# /opt/node_modules location. Thanks to PR from @brnluiz | ||
- notused:/opt/app/node_modules | ||
environment: | ||
- NODE_ENV=development | ||
|
||
volumes: | ||
notused: |
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