-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
47 lines (42 loc) · 2.5 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# use this empty Dockerfile to build your assignment
# This dir contains a Node.js app, you need to get it running in a container
# No modifications to the app should be necessary, only edit this Dockerfile
# Overview of this assignment
# use the instructions from developer below to create a working Dockerfile
# feel free to add command inline below or use a new file, up to you (but must be named Dockerfile)
# once Dockerfile builds correctly, start container locally to make sure it works on http://localhost
# then ensure image is named properly for your Docker Hub account with a new repo name
# push to Docker Hub, then go to https://hub.docker.com and verify
# then remove local image from cache
# then start a new container from your Hub image, and watch how it auto downloads and runs
# test again that it works at http://localhost
# Instructions from the app developer
# - you should use the 'node' official image, with the alpine 6.x branch
FROM node:6.14.1-alpine
# - this app listens on port 3000, but the container should launch on port 80
EXPOSE 3000
# so it will respond to http://localhost:80 on your computer
# - then it should use alpine package manager to install tini: 'apk add --update tini'
RUN apk add --update tini \
# - then it should create directory /usr/src/app for app files with 'mkdir -p /usr/src/app'
&& mkdir -p /usr/src/app
# - Node uses a "package manager", so it needs to copy in package.json file
WORKDIR /usr/src/app
COPY package.json package.json
# - then it needs to run 'npm install' to install dependencies from that file
RUN npm install \
# - to keep it clean and small, run 'npm cache clean --force' after above
&& npm cache clean --force
# - then it needs to copy in all files from current directory
COPY . /usr/src/app/
# - then it needs to start container with command '/sbin/tini -- node ./bin/www'
CMD ["/sbin/tini", "--", "node", "./bin/www"]
# - in the end you should be using FROM, RUN, WORKDIR, COPY, EXPOSE, and CMD commands
# Bonus Extra Credit
# this will not have you setting up a complete image useful for local develement, test, and prod
# it's just meant to get you started with basic Dockerfile concepts and not focus too much on
# proper Node.js use in a container. **If you happen to be a Node.js Developer**, then
# after you get through more of this course, you should come back and use my
# Node Docker Good Defaults sample project on GitHub to change this Dockerfile for
# better local development with more advanced topics
# https://github.com/BretFisher/node-docker-good-defaults