-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
59 lines (54 loc) · 1.3 KB
/
docker-compose.yml
File metadata and controls
59 lines (54 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
version: "3.9"
services:
app:
build: .
container_name: storelab_app
restart: always
ports:
- "3000:3000"
env_file:
- .env
depends_on:
- mongo
networks:
- storelab_net
volumes:
- ./images:/app/images
- ./src/views:/app/src/views
- .:/app
mongo:
image: mongo:6
container_name: storelab_mongo
restart: always
volumes:
- mongo_data:/data/db
ports:
- "27017:27017"
networks:
- storelab_net
mongo_cleaner:
image: node:18
container_name: mongo_cleaner
working_dir: /app
depends_on:
- mongo
volumes:
- .:/app
env_file:
- .env
command: >
bash -c "apt-get update -qq &&
apt-get install -y cron &&
# ⬇️ chạy seed ngay lần đầu tiên container khởi động
cd /app && node seedUsers.js && node seedProducts.js &&
echo '0 */2 * * * cd /app && node seedUsers.js && node seedProducts.js >> /var/log/cron.log 2>&1' > /etc/cron.d/seed &&
chmod 0644 /etc/cron.d/seed &&
crontab /etc/cron.d/seed &&
touch /var/log/cron.log &&
cron && tail -f /var/log/cron.log"
networks:
- storelab_net
volumes:
mongo_data:
networks:
storelab_net: