-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
143 lines (133 loc) · 4.23 KB
/
docker-compose.yml
File metadata and controls
143 lines (133 loc) · 4.23 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
version: '3.8'
x-common-env: &common-env
DB_ROOT_PASSWORD: ${DB_ROOT_PASSWORD:-snipe_root_password}
DB_NAME: ${DB_NAME:-snipeit}
MYSQLDUMP_OPTIONS: "--single-transaction --routines --triggers --extended-insert=FALSE --complete-insert --add-drop-table --disable-keys --lock-tables=false --ssl-mode=DISABLED"
BACKUP_SCHEDULE: ${BACKUP_SCHEDULE:-*/5 * * * *}
services:
mysql:
image: mysql:8.0
container_name: snipe-it-mysql
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD:-snipe_root_password}
MYSQL_DATABASE: ${DB_NAME:-snipeit}
MYSQL_USER: ${DB_USER:-snipeit}
MYSQL_PASSWORD: ${DB_PASSWORD:-snipe_password}
volumes:
- mysql_data:/var/lib/mysql
- ./backups:/backup
ports:
- "${DB_PORT:-3306}:3306"
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${DB_ROOT_PASSWORD:-snipe_root_password}"]
timeout: 20s
retries: 10
interval: 10s
command: --default-authentication-plugin=mysql_native_password
db-backup:
image: mysql:8.0
container_name: snipe-it-db-backup
depends_on:
mysql:
condition: service_healthy
environment:
<<: *common-env
volumes:
- ./backups:/backup
command: >
bash -c "
echo '🔄 Creating database backup...'
mysqldump -h mysql -u root -p$$DB_ROOT_PASSWORD $$MYSQLDUMP_OPTIONS $$DB_NAME > /backup/database.sql
echo '✅ Database backup created at /backup/database.sql'
"
restart: "no"
profiles: ["backup"]
db-restore:
image: mysql:8.0
container_name: snipe-it-db-restore
depends_on:
mysql:
condition: service_healthy
environment:
- DB_ROOT_PASSWORD=${DB_ROOT_PASSWORD:-snipe_root_password}
- DB_NAME=${DB_NAME:-snipeit}
volumes:
- ./backups:/backup
command: >
bash -c "
if [ -f /backup/database.sql ]; then
echo '🔄 Restoring database from /backup/database.sql...'
mysql -h mysql -u root -p$$DB_ROOT_PASSWORD $$DB_NAME < /backup/database.sql
echo '✅ Database restored successfully'
else
echo 'ℹ️ No database.sql found in /backup, skipping restoration'
fi
"
restart: "no"
db-backup-scheduler:
image: mysql:8.0
container_name: snipe-it-backup-scheduler
depends_on:
mysql:
condition: service_healthy
volumes:
- ./backups:/backup
environment:
<<: *common-env
command: >
bash -c "
microdnf install -y cronie
echo \"$$BACKUP_SCHEDULE root mysqldump -h mysql -u root -p$$DB_ROOT_PASSWORD $$MYSQLDUMP_OPTIONS $$DB_NAME > /backup/database.sql\" > /etc/cron.d/backup
chmod 0644 /etc/cron.d/backup
echo \"📅 Cron schedule set to: $$BACKUP_SCHEDULE\"
crond -n
"
restart: unless-stopped
snipe-it:
image: snipe/snipe-it:latest
container_name: snipe-it-app
restart: unless-stopped
depends_on:
mysql:
condition: service_healthy
environment:
# Database settings
DB_CONNECTION: mysql
DB_HOST: mysql
DB_PORT: 3306
DB_DATABASE: ${DB_NAME:-snipeit}
DB_USERNAME: ${DB_USER:-snipeit}
DB_PASSWORD: ${DB_PASSWORD:-snipe_password}
# App settings
APP_ENV: production
APP_DEBUG: ${APP_DEBUG:-false}
APP_KEY: ${SNIPE_APP_KEY}
APP_URL: ${APP_URL:-http://localhost:8080}
APP_TIMEZONE: ${APP_TIMEZONE:-UTC}
APP_LOCALE: ${APP_LOCALE:-en}
# Mail settings (optional for development)
MAIL_DRIVER: ${MAIL_DRIVER:-log}
MAIL_FROM_ADDR: ${MAIL_FROM_ADDR:-admin@localhost}
MAIL_FROM_NAME: ${MAIL_FROM_NAME:-Snipe-IT Development}
MAIL_REPLYTO_ADDR: ${MAIL_REPLYTO_ADDR:-admin@localhost}
MAIL_REPLYTO_NAME: ${MAIL_REPLYTO_NAME:-Snipe-IT Development}
# Cache settings
CACHE_DRIVER: file
SESSION_DRIVER: file
QUEUE_DRIVER: sync
volumes:
- ./data:/var/lib/snipeit
- snipe_logs:/var/www/html/storage/logs
ports:
- "8080:80"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/health"]
timeout: 10s
retries: 5
interval: 30s
volumes:
mysql_data:
driver: local
snipe_logs:
driver: local