-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathJustfile
123 lines (109 loc) · 3.45 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
set shell := ["bash", "-uc"]
# https://just.systems/
chooser := "sk --preview-window right:65% --preview 'just --show {} | (bat --language Makefile --color always --decorations never || cat)'"
uid := `id -u`
gid := `id -g`
user := uid + ":" + gid
tag := "webs"
name := "webs"
_default:
@just --list
# Interactive recipe selector (if you have `skim` installed)
choose:
@-just --choose --chooser "{{ chooser }}"
# Build OCI image for webs
build:
podman build \
--file docker/Dockerfile \
--tag "{{ tag }}"
# Start container, optionally passing flags
start *FLAGS:
podman run \
--volume .:/var/www/html \
--volume ./docker/config/apache.conf:/etc/apache2/sites-available/000-default.conf \
--volume ./docker/config/php.ini:/usr/local/etc/php/php-local.ini \
--volume ./docker/config/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini \
--volume ./docker/config/msmtprc:/etc/msmtprc \
--add-host "vyfuk.local:127.0.0.1" \
--add-host "fykos.local:127.0.0.1" \
--add-host "fol.local:127.0.0.1" \
--add-host "fof.local:127.0.0.1" \
--add-host "dsef.local:127.0.0.1" \
--env 'TZ=Europe/Prague' \
--env 'NETTE_DEVEL=1' \
--env 'MODE=dev' \
--cap-add=NET_BIND_SERVICE \
--publish 8080:8080 \
--publish 8081:8081 \
--publish 8082:8082 \
--publish 8083:8083 \
--publish 8084:8084 \
--user "{{ user }}" \
--userns keep-id \
--name "{{ name }}" \
--replace \
{{ FLAGS }} \
"{{ tag }}"
# Stop container
stop:
-podman kill "{{ name }}" &> /dev/null
-podman rm "{{ name }}" &> /dev/null
# Restart container
restart: stop (start "--detach")
# Ensure that container is running in the background
ensure:
@podman ps \
--filter "name={{ name }}" \
--filter "status=running" \
--noheading | grep "{{ name }}" &> /dev/null || just start --detach
# Execute provided commands in container
exec +CMD='bash': ensure
podman exec \
--interactive \
--tty \
"{{ name }}" \
{{ CMD }}
# Prepare dev env
setup: build ensure
just exec npm install
just exec composer install
just exec npm run build
# Watch compileable files
dev: ensure
just exec npm run dev
# Create config for FKSDB login
login:
#!/usr/bin/env bash
set -eumo pipefail
echo "Login to FKSDB"
read -r -p "login: " fksdblogin
read -r -p "password: " -s fksdbpassword
echo
target="app/config/local"
mkdir -p "$target"
for service in vyfuk fykos fol fof dsef; do
file="$target/$service.neon"
echo "# Generated from Justfile" > "$file"
i() {
echo "$1" >> "$file"
}
i "parameters:"
i " fksdbDownloader:"
i " login: '$fksdblogin'"
i " password: '$fksdbpassword'"
i " url: 'https://db.fykos.cz/api/'"
#i " gameApi:"
#i " url: 'https://game.online.fyziklani.cz/public/api/results'"
#i " login: ''"
#i " password: ''"
i " problemManagerDownloader:"
i " login: ''"
i " password: ''"
i " url: ''"
echo "configured $service"
done
echo "config files appeared in $target"
## Delete containers an OCI images
#[confirm("you sure you want to delete dev containers [y/N]")]
#clean: stop
# -podman rmi {{ tag }}