Skip to content

Commit

Permalink
Merge pull request #156 from haseebzaki-07/new_branch
Browse files Browse the repository at this point in the history
feat: Added the Dockerfile #155
  • Loading branch information
RamakrushnaBiswal authored Oct 10, 2024
2 parents 5787d34 + 18818b0 commit ca0e38f
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 0 deletions.
39 changes: 39 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

FROM node:18 AS frontend-build

WORKDIR /app/frontend
COPY frontend/package*.json ./

RUN npm install

COPY frontend/ ./

FROM node:18 AS backend-build

WORKDIR /app/backend
COPY backend/package*.json ./

RUN npm install

COPY backend/ ./

FROM node:18

WORKDIR /app

COPY --from=backend-build /app/backend ./backend
COPY --from=frontend-build /app/frontend ./frontend

COPY frontend/package*.json ./frontend/
COPY backend/package*.json ./backend/
RUN npm install --prefix frontend && npm install --prefix backend


COPY start.sh ./

RUN chmod +x start.sh

EXPOSE 5173 3000


CMD ["sh", "start.sh"]
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,22 @@ Make sure you follow our contributing guidlines:- [here](https://github.com/Ram
npm run dev
4. Open your browser at `http://localhost:3000` to see the project running! 🌟

Set-up using Dockerfile:-

1. **Build Docker Image**:
```bash
docker build -t playcafe .
2. **Run Docker Image**
```bash
docker run -p 5173:5173 -p 3000:3000 playcafe
3. Open your browser at `http://localhost:5173` to see the project running! 🌟

Set-up using docker-compose :-

1. **Build Docker Image and Run the Application**:
```bash
docker compose up --build
## 🤝 Contributing
We love contributions! 💙 Whether you're a participant in **GSSoC** or an open-source enthusiast, we welcome your input. Here's how you can contribute:
Expand Down
5 changes: 5 additions & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
npm-debug.log
.git
.gitignore
README.md
47 changes: 47 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
version: '3.8'

services:
frontend:
build:
context: .
dockerfile: Dockerfile
target: frontend-build # Reference the frontend build stage
working_dir: /app/frontend
volumes:
- ./frontend:/app/frontend # Bind-mount the frontend code to support hot-reloading
ports:
- "5173:5173"
command: ["npm", "run", "dev"]
environment:
- NODE_ENV=development

backend:
build:
context: .
dockerfile: Dockerfile
target: backend-build # Reference the backend build stage
working_dir: /app/backend
volumes:
- ./backend:/app/backend # Bind-mount the backend code to support hot-reloading
ports:
- "3000:3000"
command: ["npm", "run", "dev"]
environment:
- NODE_ENV=development

full-app:
build:
context: .
dockerfile: Dockerfile
depends_on:
- frontend
- backend
ports:
- "5173:5173"
- "3000:3000"
command: ["sh", "./start.sh"]
environment:
- NODE_ENV=production
volumes:
- ./frontend:/app/frontend
- ./backend:/app/backend
5 changes: 5 additions & 0 deletions frontend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
npm-debug.log
.git
.gitignore
README.md
3 changes: 3 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

cd frontend && npm run dev &
cd backend && npm run dev

0 comments on commit ca0e38f

Please sign in to comment.