-
-
Save atayebali/d7368be5d00a7017253223d74f446569 to your computer and use it in GitHub Desktop.
Docker Assignment Node app
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
FROM node:6-alpine | |
# - this app listens on port 3000, but the container should launch on port 80 | |
# so it will respond to http://localhost:80 on your computer | |
EXPOSE 3000 | |
# - then it should use alpine package manager to install tini: 'apk add --update tini' | |
# - then it should create directory /usr/src/app for app files with 'mkdir -p /usr/src/app' | |
RUN apk add --update tini \ | |
&& mkdir -p /usr/src/app | |
WORKDIR /usr/src/app | |
# - Node uses a "package manager", so it needs to copy in package.json file | |
COPY package.json package.json | |
# - then it needs to run 'npm install' to install dependencies from that file | |
# - to keep it clean and small, run 'npm cache clean' after above | |
RUN npm install \ | |
&& npm cache clean | |
# - then it needs to copy in all files from current directory | |
COPY . . | |
# - then it needs to start container with command 'tini -- node ./bin/www' | |
CMD ["tini", "--", "node", "./bin/www" ] | |
# - in the end you should be using FROM, RUN, WORKDIR, COPY, EXPOSE, and CMD commands |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment