From 16d9b3d512357b40421ed984335b7a323c5b05d0 Mon Sep 17 00:00:00 2001 From: glproj Date: Fri, 1 Mar 2024 14:44:10 -0300 Subject: [PATCH] add live-reload for development with docker --- apps/web/backend/.dockerignore | 1 + apps/web/backend/backend_dev.Dockerfile | 6 +++++ apps/web/docker-compose-dev.yaml | 27 +++++++++++++++++++++++ apps/web/frontend/.dockerignore | 1 + apps/web/frontend/frontend_dev.Dockerfile | 5 +++++ 5 files changed, 40 insertions(+) create mode 100644 apps/web/backend/.dockerignore create mode 100644 apps/web/backend/backend_dev.Dockerfile create mode 100644 apps/web/docker-compose-dev.yaml create mode 100644 apps/web/frontend/.dockerignore create mode 100644 apps/web/frontend/frontend_dev.Dockerfile diff --git a/apps/web/backend/.dockerignore b/apps/web/backend/.dockerignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/apps/web/backend/.dockerignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/apps/web/backend/backend_dev.Dockerfile b/apps/web/backend/backend_dev.Dockerfile new file mode 100644 index 0000000..199923e --- /dev/null +++ b/apps/web/backend/backend_dev.Dockerfile @@ -0,0 +1,6 @@ +FROM node:14-alpine3.15 +COPY . /back +WORKDIR /back +ENV DB="mongodb" +RUN npm install && npm install nodemon +ENTRYPOINT ["npx", "nodemon"] diff --git a/apps/web/docker-compose-dev.yaml b/apps/web/docker-compose-dev.yaml new file mode 100644 index 0000000..4e8deca --- /dev/null +++ b/apps/web/docker-compose-dev.yaml @@ -0,0 +1,27 @@ +services: + mongodb: + image: mongo:5.0.2 + ports: + - "27017:27017" + container_name: mongodb + restart: always + backend: + build: + context: backend + dockerfile: backend_dev.Dockerfile + volumes: + - type: bind + source: ./backend + target: /back + depends_on: + - mongodb + frontend: + ports: + - "3000:3000" + build: + context: frontend + dockerfile: frontend_dev.Dockerfile + volumes: + - type: bind + source: ./frontend + target: /front \ No newline at end of file diff --git a/apps/web/frontend/.dockerignore b/apps/web/frontend/.dockerignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/apps/web/frontend/.dockerignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/apps/web/frontend/frontend_dev.Dockerfile b/apps/web/frontend/frontend_dev.Dockerfile new file mode 100644 index 0000000..b4ec892 --- /dev/null +++ b/apps/web/frontend/frontend_dev.Dockerfile @@ -0,0 +1,5 @@ +FROM node:14-alpine3.15 +COPY . /front +WORKDIR /front +RUN npm i && npm i nodemon +ENTRYPOINT ["npx", "nodemon"] \ No newline at end of file