From 9e73578cc368d41dd80a6f86599e2d75b5e52a67 Mon Sep 17 00:00:00 2001 From: Hama Mubin Date: Sun, 10 Nov 2024 13:53:31 +0530 Subject: [PATCH] added dockerfile and docker-compose --- backend/dockerfile | 14 ++++++++++++++ docker-compose.yml | 24 ++++++++++++++++++++++++ frontend/dockerfile | 20 ++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 backend/dockerfile create mode 100644 docker-compose.yml create mode 100644 frontend/dockerfile diff --git a/backend/dockerfile b/backend/dockerfile new file mode 100644 index 0000000..6e3d6ab --- /dev/null +++ b/backend/dockerfile @@ -0,0 +1,14 @@ +# backend/Dockerfile +FROM node:18 + +WORKDIR /app + +COPY package.json ./ + +RUN npm install + +COPY . . + +EXPOSE 3000 + +CMD ["npm", "start"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..ce4f75f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,24 @@ +version: '3.8' + +services: + backend: + build: + context: ./backend + ports: + - "3000:3000" + environment: + - NODE_ENV=production + volumes: + - ./backend:/app + depends_on: + - frontend + + frontend: + build: + context: ./frontend + ports: + - "80:80" + environment: + - NODE_ENV=production + volumes: + - ./frontend:/app diff --git a/frontend/dockerfile b/frontend/dockerfile new file mode 100644 index 0000000..b591814 --- /dev/null +++ b/frontend/dockerfile @@ -0,0 +1,20 @@ +# frontend/Dockerfile +FROM node:18 AS build + +WORKDIR /app + +COPY package.json ./ + +RUN npm install + +COPY . . + +RUN npm run build + +FROM nginx:stable-alpine AS production + +COPY --from=build /app/dist /usr/share/nginx/html + +EXPOSE 80 + +CMD ["nginx", "-g", "daemon off;"]