-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathrun
executable file
·74 lines (58 loc) · 1.6 KB
/
run
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
#!/usr/bin/env bash
set -eo pipefail
# shellcheck disable=SC2046
export $(grep -v '^#' .env | xargs)
# -----------------------------------------------------------------------------
function ssl-cert {
# If you'd like to run in https
openssl genrsa -out server.key 2048
openssl req -new -x509 -nodes \
-config server.cnf \
-key server.key \
-out server.crt \
-days 365
chmod 600 server.key
chmod 644 server.crt
}
function cmd {
# Run any command you want in the web container
docker compose exec web "${@}"
}
function flask {
# Run any Flask commands
docker compose exec web flask "${@}"
}
function lint:dockerfile {
# Lint Dockerfile
docker container run --rm -i -v ./Dockerfile:/Dockerfile \
hadolint/hadolint hadolint "${@}" /Dockerfile
}
function lint {
# Lint Python code
docker compose exec web ruff check "${@}"
}
function test {
# Run test suite
docker compose exec web python -m pytest "${@}"
}
function shell {
# Start a shell session in the web container
docker compose exec web bash "${@}"
}
function psql {
# Connect to PostgreSQL
# shellcheck disable=SC1091
docker compose exec postgres psql -U "${POSTGRES_USER}" -d "${POSTGRES_DB}" "${@}"
}
function redis-cli {
# Connect to Redis
docker compose exec redis redis-cli "${@}"
}
function help {
printf "%s <task> [args]\n\nTasks:\n" "${0}"
compgen -A function | grep -v "^_" | cat -n
printf "\nExtended help:\n Each task has comments for general usage\n"
}
# This idea is heavily inspired by: https://github.com/adriancooney/Taskfile
TIMEFORMAT=$'\nTask completed in %3lR'
time "${@:-help}"