Skip to content

Commit 46833dd

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

6 files changed

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