Skip to content

Commit e0c03ee

Browse files
committed
test script and dynamic server with --scale on dockercompose
1 parent b971741 commit e0c03ee

4 files changed

Lines changed: 23 additions & 30 deletions

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,16 @@ Draw together on a shared canvas — like r/place, but for friends.
2828
### Docker (Recommended)
2929

3030
```bash
31-
docker compose up
31+
docker compose up -d --scale server=3
3232
```
3333

3434
| Service | URL |
3535
|---------|-----|
3636
| App | http://localhost:5173 |
3737
| API Docs | http://localhost:3000/api-docs |
3838

39+
> 💡 **Dynamic Scaling:** You can add more server instances at any time using `--scale server=N`. Nginx is configured with `least_conn` to balance active connections across all instances.
40+
3941
### Manual
4042

4143
```bash

docker-compose.yml

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,39 +30,18 @@ services:
3030
networks:
3131
- pixie-net
3232

33-
server-a:
33+
server:
3434
build:
3535
context: ./server
3636
target: dev-stage
37-
container_name: pixie-server-a
37+
image: pixie-server:dev
38+
deploy:
39+
endpoint_mode: dnsrr
3840
environment:
3941
PORT: 3000
4042
MONGO_URI: mongodb://mongo:27017/pixie
4143
CLIENT_ORIGIN: http://localhost:5173
4244
JWT_SECRET: dev-secret-key
43-
SERVER_ID: server-a
44-
REDIS_URL: redis://redis:6379
45-
volumes:
46-
- ./server/src:/app/src
47-
- ./server/pixie-api.yaml:/app/pixie-api.yaml
48-
depends_on:
49-
- mongo
50-
- redis
51-
networks:
52-
- pixie-net
53-
command: npm run dev
54-
55-
server-b:
56-
build:
57-
context: ./server
58-
target: dev-stage
59-
container_name: pixie-server-b
60-
environment:
61-
PORT: 3000
62-
MONGO_URI: mongodb://mongo:27017/pixie
63-
CLIENT_ORIGIN: http://localhost:5173
64-
JWT_SECRET: dev-secret-key
65-
SERVER_ID: server-b
6645
REDIS_URL: redis://redis:6379
6746
volumes:
6847
- ./server/src:/app/src
@@ -82,8 +61,7 @@ services:
8261
volumes:
8362
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
8463
depends_on:
85-
- server-a
86-
- server-b
64+
- server
8765
networks:
8866
- pixie-net
8967

nginx/nginx.conf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ events {
44

55
http {
66
upstream backend {
7-
server server-a:3000;
8-
server server-b:3000;
7+
least_conn;
8+
# Docker's internal DNS will resolve 'server' to all container IPs
9+
server server:3000;
910
}
1011

1112
server {

package.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "pixie",
3+
"version": "1.0.0",
4+
"private": true,
5+
"description": "Real-time collaborative pixel art editor",
6+
"scripts": {
7+
"test": "bash test.sh"
8+
},
9+
"engines": {
10+
"node": ">=24.0.0"
11+
}
12+
}

0 commit comments

Comments
 (0)