-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjustfile
105 lines (79 loc) · 2.73 KB
/
justfile
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
set dotenv-load
set positional-arguments
project := env_var('PROJECT_NAME')
backup_file := justfile_directory() + '/docker/volumes/backups/${MYSQL_DATABASE}_backup_latest.sql.gz'
cnf := replace_regex('[client]
user=$MYSQL_USER
password=$MYSQL_PASSWORD
[clientroot]
user=root
password=$MYSQL_ROOT_PASSWORD
[mysql]
database=$MYSQL_DATABASE', '[\n]', "\\\\n")
dump_options := '--defaults-group-suffix=root --hex-blob --net-buffer-length 100K --routines --databases $MYSQL_DATABASE'
# List available recipes.
help:
just -lu
# Analyze all .php source files.
check:
vendor/bin/phpstan analyse -l 9 classes util views
# Start all containers. Accepts arguments like `-d` to start in background.
up *args='':
docker compose up $@
# Stop all containers.
down:
docker compose down
# Build the server image.
build:
docker compose build
# Start and recreate containers.
reload:
docker compose up -d --force-recreate
# Refresh leaderboard cache.
cache:
docker exec -u www-data {{project}}-server php -f /var/www/html/util/refreshCache.php > /dev/null 2>&1
# Update Steam profiles.
update-profiles:
docker exec -u www-data {{project}}-server php -f /var/www/html/util/fetchImportantProfileData.php
# Open shell in server container.
debug: server-debug
# Open shell in server container.
server-debug:
docker exec -ti {{project}}-server bash
# Open shell in server container as root user.
root:
docker exec -u root -ti {{project}}-server bash
# Restart server container.
server-restart:
docker container restart {{project}}-server
# Stop server container.
server-stop:
docker container stop {{project}}-server
# Run server tests.
test:
./test
# Connect to database.
db: db-conf
docker exec -ti {{project}}-db mysql
# Configure database connection.
db-conf:
docker exec {{project}}-db bash -c 'printf {{cnf}} > /etc/my.cnf'
# Open shell in database container.
db-debug: db-conf
docker exec -ti {{project}}-db bash
# Restart database container.
db-restart:
docker container restart {{project}}-db
# Stop database container.
db-stop:
docker container stop {{project}}-db
# Dump and compress a backup of the database.
db-dump: db-conf
docker exec {{project}}-db bash -c 'mysqldump {{dump_options}} | gzip -8 > /backups/${MYSQL_DATABASE}_dump_$(date +%Y-%m-%d-%H.%M.%S).sql.gz'
# Only dump a backup of the database.
db-dump-raw: db-conf
docker exec {{project}}-db bash -c 'mysqldump {{dump_options}} > /backups/${MYSQL_DATABASE}_dump_$(date +%Y-%m-%d-%H.%M.%S).sql'
# Backup and upload database.
backup: db-conf
docker exec {{project}}-db bash -c 'mysqldump {{dump_options}} | gzip -8 > /backups/${MYSQL_DATABASE}_backup_latest.sql.gz'
deno run --env -A backup.ts {{backup_file}} --user-agent=${SERVER_NAME}