From cce8f99f4e929c0428fa3dce0c2d5728d29ecc38 Mon Sep 17 00:00:00 2001 From: tharinee thuengnok Date: Thu, 12 May 2022 15:24:32 +0700 Subject: [PATCH 1/3] Add dockerfile --- Dockerfile | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9403bdb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM node:16-alpine AS development +ENV NODE_ENV development +WORKDIR /app +COPY package.json ./ +COPY yarn.lock ./ +RUN yarn +COPY . ./ +EXPOSE 3000 +CMD [ "yarn", "start" ] + +FROM node:16-alpine AS builder +ENV NODE_ENV production +WORKDIR /app +COPY package.json ./ +COPY yarn.lock ./ +RUN yarn install --production +COPY . ./ +RUN yarn build + +FROM nginx:1.21.0-alpine AS production +COPY --from=builder /app/build /usr/share/nginx/html +COPY nginx.conf /etc/nginx/conf.d/default.conf +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file From 0e6e00b7aa140f41cf7bd5e1b38be91211242f13 Mon Sep 17 00:00:00 2001 From: "bantita.b (June)" Date: Thu, 12 May 2022 15:27:12 +0700 Subject: [PATCH 2/3] Add docker-compose --- docker-compose.dev.yml | 13 +++++++++++++ docker-compose.prod.yml | 9 +++++++++ 2 files changed, 22 insertions(+) create mode 100644 docker-compose.dev.yml create mode 100644 docker-compose.prod.yml diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml new file mode 100644 index 0000000..a0bfe15 --- /dev/null +++ b/docker-compose.dev.yml @@ -0,0 +1,13 @@ +version: "3.8" + +services: + app: + container_name: app-dev + image: app-dev + build: + context: . + target: development + volumes: + - ./src:/app/src + ports: + - 3000:3000 \ No newline at end of file diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml new file mode 100644 index 0000000..8a5cd27 --- /dev/null +++ b/docker-compose.prod.yml @@ -0,0 +1,9 @@ +version: "3.8" + +services: + app: + container_name: app-prod + image: app-prod + build: + context: . + target: production \ No newline at end of file From 3114d80924ed1a830b88b6096b1cb311666f76fc Mon Sep 17 00:00:00 2001 From: tharinee thuengnok Date: Thu, 12 May 2022 16:09:04 +0700 Subject: [PATCH 3/3] ADD dockerignore and nginxconfig --- .dockerignore | 2 ++ nginx.conf | 9 +++++++++ 2 files changed, 11 insertions(+) create mode 100644 .dockerignore create mode 100644 nginx.conf diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..390c521 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +**/node_modules +build \ No newline at end of file diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..d64c1a5 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,9 @@ +server { + listen 80; + + location / { + root /usr/share/nginx/html/; + include /etc/nginx/mime.types; + try_files $uri $uri/ /index.html; + } +} \ No newline at end of file