Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/dockerize app for local development #915

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
package-lock.json
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,24 @@ npm run dev

> If you still facing issue, then follow [this stackoverflow thread](https://stackoverflow.com/questions/69692842/error-message-error0308010cdigital-envelope-routinesunsupported). It has so many different types of opinions. You definitely have solution after going through the thread.

## Docker Compose for local development

- setup additional env variables, if necessary in the below file

```bash
docker-compose.yml
```

- After the necessary configurations run below command :

```bash
docker-compose up -d
```

This will build the images and bring up the containers for frontend, backend and mongodb.

**_NOTE:_** This docker-compose setup is associated for local development only.

## Contributing

1.[How to contribute](https://github.com/idurar/idurar-erp-crm/blob/master/CONTRIBUTING.md#how-to-contribute)
Expand Down
15 changes: 15 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:20.9.0-alpine

WORKDIR /usr/src/app

RUN npm install -g [email protected]

COPY package*.json ./

COPY . .

RUN npm install

EXPOSE 8888

CMD ["npm", "run", "dev"]
42 changes: 42 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
version: "3.8"
services:
backend:
build: ./backend
volumes:
- ./backend:/usr/src/app
- /usr/src/app/node_modules
ports:
- "8888:8888"
environment:
- NODE_ENV=development
- DATABASE=mongodb://mongo:27017/local-idurar-erp-crp
- PORT=8888
- NODE_OPTIONS=--openssl-legacy-provider
- JWT_SECRET=secret_key_1234

command: sh -c "npm run setup && npm run dev"

depends_on:
- mongo

frontend:
build: ./frontend
volumes:
- ./frontend:/usr/src/app
- /usr/src/app/node_modules
ports:
- "3000:3000"
environment:
- NODE_ENV=development
- REACT_APP_API_URL=http://backend:8888/api
- NODE_OPTIONS=--openssl-legacy-provider

mongo:
image: mongo
volumes:
- mongodb_data:/data/db
ports:
- "27017:27017"

volumes:
mongodb_data:
16 changes: 16 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM node:20.9.0-alpine

WORKDIR /usr/src/app

RUN npm install -g [email protected]

COPY package*.json ./
COPY vite.config.js ./

COPY . .

RUN npm install

EXPOSE 3000

CMD ["npm", "run", "local"]
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
},
"scripts": {
"dev": "vite",
"local": "vite --host",
"build": "vite build",
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview",
Expand Down