Skip to content

Commit a00405a

Browse files
feat: dockerized the whole project
1 parent 9176389 commit a00405a

File tree

8 files changed

+95
-2
lines changed

8 files changed

+95
-2
lines changed

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,45 @@ collab-canvas/
8787
## 🚀 Getting Started
8888

8989
Follow these steps to set up and run the project locally.
90+
- **Option 1: Docker (Recommended)** – The simplest way to get running with a single command.
91+
- **Option 2: Manual Setup** – The traditional way if you want to manage the services yourself.
92+
93+
## Option 1: Run with Docker (Recommended) 🐳
94+
95+
This method starts the **client**, **server**, and a **MongoDB database** all at once.
96+
You do **not** need Node.js or MongoDB installed on your machine.
97+
### Prequisites: you must have docker desktop installed and running
98+
99+
### Clone the Repository
100+
101+
```bash
102+
git clone https://github.com/your-username/collab-canvas.git
103+
cd collab-canvas
104+
```
105+
106+
### Run with Docker Compose
107+
108+
```bash
109+
docker-compose up --build
110+
```
111+
112+
Docker will build the images and start all three containers.
113+
114+
Your application is now running:
115+
116+
Frontend Client: http://localhost:3000
117+
118+
Backend Server: http://localhost:5000
119+
120+
MongoDB Database: Accessible to the server at mongodb://db:27017
121+
122+
Note: The first build may take a few minutes. Subsequent builds will be faster.
123+
To stop all services, press Ctrl + C in your terminal, then run:
124+
```bash
125+
docker-compose down
126+
```
127+
128+
## Option 2
90129

91130
### Prerequisites
92131

client/.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
.env

client/Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM node:20-alpine
2+
WORKDIR /app
3+
COPY package*.json ./
4+
RUN npm install
5+
COPY . .
6+
EXPOSE 5173
7+
CMD ["npm", "run", "dev", "--", "--host"]

client/src/components/StrokeControl.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { Slider } from "./ui/slider";
2-
1+
import { Slider } from "./ui/Slider";
32
export const StrokeControl = ({ strokeWidth, onStrokeWidthChange }) => {
43
return (
54
<div className="fixed right-6 top-1/2 -translate-y-1/2 z-50">

docker-compose.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
version: '3.8'
2+
3+
services:
4+
5+
client:
6+
build: ./client
7+
ports:
8+
- "3000:5173"
9+
depends_on:
10+
- server
11+
12+
server:
13+
build: ./server
14+
ports:
15+
- "${SERVER_PORT:-5000}:5000"
16+
environment:
17+
PORT: 5000
18+
CORS_ORIGIN: ${CORS_ORIGIN:-http://localhost:3000}
19+
MONGO_URI: ${MONGO_URI:-mongodb://db:27017/collabcanvas}
20+
JWT_SECRET: ${JWT_SECRET:-THIS_IS_A_DEFAULT_NOT_A_SECRET}
21+
depends_on:
22+
- db
23+
24+
db:
25+
image: mongo:latest
26+
ports:
27+
- "27017:27017"
28+
volumes:
29+
- mongo-data:/data/db
30+
31+
volumes:
32+
mongo-data:

server/.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
.env

server/.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
PORT=3000
2+
MONGO_URI=your_mongodb_connection_string_here
3+
CORS_ORIGIN=http://localhost:5173
4+
JWT_SECRET=your_jwt_secret_here

server/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM node:20-alpine
2+
WORKDIR /app
3+
4+
COPY package*.json ./
5+
RUN npm install
6+
COPY . .
7+
EXPOSE 5000
8+
CMD ["npm", "run", "dev"]

0 commit comments

Comments
 (0)