diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..dd0ab5c6 --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/README.md b/README.md index 3754393d..f22ecd58 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/backend/.dockerignore b/backend/.dockerignore new file mode 100644 index 00000000..98ff58ae --- /dev/null +++ b/backend/.dockerignore @@ -0,0 +1,5 @@ +node_modules +npm-debug.log +.git +.gitignore +README.md diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..7339920e --- /dev/null +++ b/docker-compose.yml @@ -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 diff --git a/frontend/.dockerignore b/frontend/.dockerignore new file mode 100644 index 00000000..98ff58ae --- /dev/null +++ b/frontend/.dockerignore @@ -0,0 +1,5 @@ +node_modules +npm-debug.log +.git +.gitignore +README.md diff --git a/start.sh b/start.sh new file mode 100644 index 00000000..f82893af --- /dev/null +++ b/start.sh @@ -0,0 +1,3 @@ + +cd frontend && npm run dev & +cd backend && npm run dev