Node.js 서버 Docker로 배포하기

JinWooHyun·2021년 1월 14일
0

Dockerfile 작성

FROM node:12
WORKDIR /app
COPY package*.json /app
RUN npm install
COPY . /app
CMD [ "npm", "start" ]
EXPOSE 8080

.dockerignore 파일 작성

node_modules
npm-debug.log

Docker Build

docker build -t {Dockerhub 이름(user 이름)/이미지 이름}:{tag} .
[+] Building 63.7s (11/11) FINISHED
 => [internal] load build definition from Dockerfile                                                                                                                                       0.1s 
 => => transferring dockerfile: 156B                                                                                                                                                       0.0s 
 => [internal] load .dockerignore                                                                                                                                                          0.0s 
 => => transferring context: 2B                                                                                                                                                            0.0s 
 => [internal] load metadata for docker.io/library/node:12                                                                                                                                 3.8s 
 => [auth] library/node:pull token for registry-1.docker.io                                                                                                                                0.0s 
 => [1/5] FROM docker.io/library/node:12@sha256:9c5e64d867035cd2b08dbc4a537dbd638c8d761be627c85a00e585309489d6e6                                                                          48.3s 
 => => resolve docker.io/library/node:12@sha256:9c5e64d867035cd2b08dbc4a537dbd638c8d761be627c85a00e585309489d6e6                                                                           0.0s 
 => => sha256:953fe5c215cb5f929e0e42e5a1011f33edce9278a650faf10655e855a670f79f 10.75MB / 10.75MB                                                                                           4.6s 
 => => sha256:9c5e64d867035cd2b08dbc4a537dbd638c8d761be627c85a00e585309489d6e6 776B / 776B                                                                                                 0.0s 
 => => sha256:9756a2cb8e53ee413407e1a50cb7fe8c7c9c0bf3ab6fdd9c560c51a6db40259d 7.80kB / 7.80kB                                                                                             0.0s 
 => => sha256:2587235a7635c6991dfee9791c7977ab29694cf73bc64c3c5a79097ca99364d1 45.38MB / 45.38MB                                                                                          16.5s 
 => => sha256:d4d3f270c7deffd353181076af3b5746c8dbeac5abf454169a75e7822587bdab 4.34MB / 4.34MB                                                                                             3.0s 
 => => sha256:35e73aa5be74d261b24884579cf8808d2b13e1d68739887215b08e80c891939e 2.21kB / 2.21kB                                                                                             0.0s 
 => => sha256:ed36dafe30e3d9c4fde74478dae686f851d7e93b719dc3165d8eb7e8be9305d9 50.11MB / 50.11MB                                                                                          24.9s 
 => => sha256:00e912dd434d537c339ad16f37836cef5f5984fe0da0d0399fa79f47e31f1057 214.31MB / 214.31MB                                                                                        40.6s 
 => => extracting sha256:2587235a7635c6991dfee9791c7977ab29694cf73bc64c3c5a79097ca99364d1                                                                                                  4.3s 
 => => sha256:dd25ee3ea38e0207708e76e6dcd112e86b43dfbff71976f17827b8188174922f 4.17kB / 4.17kB                                                                                            17.1s 
 => => sha256:2a9b744d457d7597b92121f69cfd5b789f355696cad00f0bb9668146fdb5c965 23.73MB / 23.73MB                                                                                          31.1s 
 => => extracting sha256:953fe5c215cb5f929e0e42e5a1011f33edce9278a650faf10655e855a670f79f                                                                                                  0.9s 
 => => extracting sha256:d4d3f270c7deffd353181076af3b5746c8dbeac5abf454169a75e7822587bdab                                                                                                  0.3s 
 => => sha256:cc5d09c61fdfb9d4ae4447c181d01f400463f831614bc33af90fd7c351eee7f3 2.38MB / 2.38MB                                                                                            28.8s 
 => => extracting sha256:ed36dafe30e3d9c4fde74478dae686f851d7e93b719dc3165d8eb7e8be9305d9                                                                                                  5.2s 
 => => sha256:2f2248a9e4753651a10a46d2a5643ac4c66ae64a01022b11d423f619edb8a3b6 295B / 295B                                                                                                29.3s 
 => => extracting sha256:00e912dd434d537c339ad16f37836cef5f5984fe0da0d0399fa79f47e31f1057                                                                                                  5.7s 
 => => extracting sha256:dd25ee3ea38e0207708e76e6dcd112e86b43dfbff71976f17827b8188174922f                                                                                                  0.0s 
 => => extracting sha256:2a9b744d457d7597b92121f69cfd5b789f355696cad00f0bb9668146fdb5c965                                                                                                  1.1s 
 => => extracting sha256:cc5d09c61fdfb9d4ae4447c181d01f400463f831614bc33af90fd7c351eee7f3                                                                                                  0.1s
 => => extracting sha256:2f2248a9e4753651a10a46d2a5643ac4c66ae64a01022b11d423f619edb8a3b6                                                                                                  0.0s 
 => [internal] load build context                                                                                                                                                         33.4s 
 => => transferring context: 62.55MB                                                                                                                                                      33.4s 
 => [2/5] WORKDIR /app                                                                                                                                                             4.1s 
 => [3/5] COPY package*.json /app                                                                                                                                                            0.2s 
 => [4/5] RUN npm install                                                                                                                                                                  5.4s 
 => [5/5] COPY . /app                                                                                                                                                                         0.7s 
 => exporting to image                                                                                                                                                                     1.0s 
 => => exporting layers                                                                                                                                                                    0.9s 
 => => writing image sha256:4b308db117f198eb24a1ba78633831fe16c1bdcba5099b0896311658af86823c                                                                                               0.0s 
 => => naming to docker.io/library/xxxxxx:1.0

Docker Image Upload

docker push {Dockerhub 이름(user 이름)/이미지 이름}:{tag}
profile
Unicorn Developer

0개의 댓글