-
Notifications
You must be signed in to change notification settings - Fork 310
/
Copy pathnode.dockerfile
37 lines (24 loc) · 1.15 KB
/
node.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
# Build: docker build -f node.dockerfile -t nodeapp .
# Option 1: Create a custom bridge network and add containers into it
# docker network create --driver bridge isolated_network
# docker run -d --net=isolated_network --name mongodb mongo
# NOTE: $(pwd) in the following line is for Mac and Linux. Use ${PWD} for Powershell.
# See https://blog.codewithdan.com/docker-volumes-and-print-working-directory-pwd/ syntax examples.
# docker run -d --net=isolated_network --name nodeapp -p 3000:3000 -v $(pwd)/logs:/var/www/logs nodeapp
# Seed the database with sample database
# Run: docker exec nodeapp node dbSeeder.js
# Option 2 (Legacy Linking - this is the OLD way)
# Start MongoDB and Node (link Node to MongoDB container with legacy linking)
# docker run -d --name my-mongodb mongo
# docker run -d -p 3000:3000 --link my-mongodb:mongodb --name nodeapp danwahlin/nodeapp
FROM node:alpine
LABEL author="Dan Wahlin"
ARG PACKAGES=nano
ENV TERM xterm
RUN apk update && apk add $PACKAGES
WORKDIR /var/www
COPY package*.json ./
RUN npm install
COPY . ./
EXPOSE 3000
ENTRYPOINT ["npm", "start"]