Skip to content

Commit d972912

Browse files
committed
feat: add Docker support and setup documentation
1 parent 34f4a2c commit d972912

6 files changed

Lines changed: 110 additions & 0 deletions

File tree

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,30 @@ After running the seed script, you can log in immediately using these credential
262262

263263
<br/>
264264

265+
## (Alternatively)Running with Docker
266+
267+
### Start all services
268+
269+
```bash
270+
docker compose up --build
271+
```
272+
273+
### Stop services
274+
275+
```bash
276+
docker compose down
277+
```
278+
279+
### Seed the database
280+
281+
```bash
282+
docker compose exec backend node seed.js
283+
```
284+
285+
Frontend: http://localhost:5173
286+
287+
Backend: http://localhost:5000
288+
265289
## 🛠 Roadmap / Not Yet Implemented
266290

267291
A few things exist in some form but aren't finished yet:

backend/.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
.git
3+
.gitignore
4+
npm-debug.log
5+
Dockerfile

backend/Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM node:22-alpine
2+
3+
WORKDIR /app
4+
COPY package*.json ./
5+
6+
RUN npm ci
7+
8+
COPY . .
9+
10+
EXPOSE 5000
11+
12+
CMD [ "npm", "start" ]

docker-compose.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
services:
2+
mongodb:
3+
image: mongo:8
4+
5+
ports:
6+
- "27017:27017"
7+
8+
volumes:
9+
- mongo-data:/data/db
10+
11+
backend:
12+
build:
13+
context: ./backend
14+
15+
container_name: learnhub-backend
16+
17+
ports:
18+
- "5000:5000"
19+
20+
env_file:
21+
- ./backend/.env
22+
23+
environment:
24+
MONGO_URI: mongodb://mongodb:27017/learnhub
25+
26+
depends_on:
27+
- mongodb
28+
29+
volumes:
30+
- ./backend:/app
31+
- /app/node_modules
32+
33+
frontend:
34+
build:
35+
context: ./frontend
36+
37+
container_name: learnhub-frontend
38+
39+
ports:
40+
- "5173:5173"
41+
42+
depends_on:
43+
- backend
44+
45+
volumes:
46+
- ./frontend:/app
47+
- /app/node_modules
48+
49+
volumes:
50+
mongo-data:

frontend/.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules
2+
dist
3+
.git
4+
.gitignore
5+
npm-debug.log
6+
Dockerfile

frontend/Dockerfile

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

0 commit comments

Comments
 (0)