Skip to content

Commit f22139b

Browse files
barakivaCopilotcolisee
authored
Introducing Podman Quadlets, its automation using vscode tasks, and sanity testing using pytest (#197)
* Added podman build tasks as well as logging. Added quadlets as a Docker Compose equivalent. Added podman compose build scripts * Most of quadlets now works. * Writing infra sanity tests to speed up debugging. * Cron bug fixed. Added pytest and removed goss. Made scripts more robust * Going to the office push * Made tasks.json load shell so its conscious of docker context. * All tests pass for podman and docker * Ignored a couple of python files * Tests pass for docker. Cleaned up. * Tests pass for podman quadlets tasks * Added documentation for using podman quadlets, the equilvaent of docker compose * Cleaned up unecessary pytest config * Applied linter fixes * Update tests/test_docker_db.py Make testing not leak credentials Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update scripts/stop Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Cleaned stale code. Improved python config, improved quadlets config * cleaned up tests * Extracted multi-line script into a line referenced by Dockerfile as a compromise for not using heredox. * fix: fixed linting error * fix: ok now the linting problem is fixed for real * fix: ok now for real for real this is fixed and linting will pass god willing * Update .examples/docker/docker-compose-local.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Robin ALEXANDER <colisee@hotmail.com>
1 parent c66263d commit f22139b

25 files changed

Lines changed: 799 additions & 40 deletions

.examples/docker/crontab

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Every minute
2+
* * * * * php -f /var/www/html/Jobs/autorelease.php
3+
* * * * * php -f /var/www/html/Jobs/sendmissedcheckin.php
4+
* * * * * php -f /var/www/html/Jobs/sendreminders.php
5+
* * * * * php -f /var/www/html/Jobs/sendwaitlist.php
6+
7+
# Every day at midnight
8+
0 0 * * * php -f /var/www/html/Jobs/sendseriesend.php
9+
0 0 * * * php -f /var/www/html/Jobs/sessioncleanup.php
10+
0 0 * * * php -f /var/www/html/Jobs/deleteolddata.php

.examples/docker/db.env

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
MYSQL_ROOT_PASSWORD=db_root_pwd
21
TZ=Europe/Zurich
32
PUID=1000
4-
PGID=1000
3+
PGID=1000
4+
MYSQL_ROOT_PASSWORD=db_root_pwd
5+
MYSQL_DATABASE=librebooking
6+
MYSQL_USER=lb_user
7+
MYSQL_PASSWORD=db_user_pwd

.examples/docker/docker-compose-local.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ services:
2727
- app
2828
volumes:
2929
- app_conf:/config
30+
- ./crontab:/config/lb-jobs-cron:ro
3031
env_file:
3132
- lb.env
3233

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
__pycache__/
2+
*.pyc
3+
.mypy_cache/
4+
.venv/

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"python-envs.defaultEnvManager": "ms-python.python:poetry",
3+
"python-envs.defaultPackageManager": "ms-python.python:poetry"
4+
}

.vscode/tasks.json

Lines changed: 97 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
{
22
"version": "2.0.0",
33
"tasks": [
4-
// Logging
4+
// Docker
5+
// Logging
56
{
67
"label": "Logs: librebooking (docker)",
78
"command": "docker compose --file docker-compose-local.yml logs app -f",
89
"type": "shell",
910
"options": {
1011
"cwd": "${workspaceFolder}/.examples/docker",
11-
"env": {
12-
"DOCKER_HOST": "unix:///run/docker.sock" // Sometimes the tasks shell doesnt inherit .bashrc DOCKER_HOST, neither the docker context
12+
"shell": {
13+
"executable": "bash",
14+
"args": ["-i", "-c"]
1315
}
1416
},
1517
"presentation": {
@@ -23,8 +25,9 @@
2325
"type": "shell",
2426
"options": {
2527
"cwd": "${workspaceFolder}/.examples/docker",
26-
"env": {
27-
"DOCKER_HOST": "unix:///run/docker.sock"
28+
"shell": {
29+
"executable": "bash",
30+
"args": ["-i", "-c"]
2831
}
2932
},
3033
"presentation": {
@@ -38,8 +41,9 @@
3841
"type": "shell",
3942
"options": {
4043
"cwd": "${workspaceFolder}/.examples/docker",
41-
"env": {
42-
"DOCKER_HOST": "unix:///run/docker.sock"
44+
"shell": {
45+
"executable": "bash",
46+
"args": ["-i", "-c"]
4347
}
4448
},
4549
"presentation": {
@@ -66,8 +70,9 @@
6670
"type": "shell",
6771
"options": {
6872
"cwd": "${workspaceFolder}/.examples/docker",
69-
"env": {
70-
"DOCKER_HOST": "unix:///run/docker.sock"
73+
"shell": {
74+
"executable": "bash",
75+
"args": ["-i", "-c"]
7176
}
7277
},
7378
"presentation": {
@@ -78,36 +83,107 @@
7883
// Booting
7984
{
8085
"label": "Hard Restart: all (docker)",
81-
"command": "docker compose --file docker-compose-local.yml down --remove-orphans && docker compose --file docker-compose-local.yml up -d ",
86+
"command": "docker compose --file docker-compose-local.yml down --remove-orphans && docker compose --file docker-compose-local.yml up -d --pull always",
87+
"type": "shell",
8288
"options": {
8389
"cwd": "${workspaceFolder}/.examples/docker",
84-
"env": {
85-
"DOCKER_HOST": "unix:///run/docker.sock"
90+
"shell": {
91+
"executable": "bash",
92+
"args": ["-i", "-c"]
8693
}
87-
},
88-
"type": "shell"
94+
}
8995
},
9096
{
9197
"label": "Start: all (docker)",
9298
"command": "docker compose --file docker-compose-local.yml up -d",
99+
"type": "shell",
93100
"options": {
94101
"cwd": "${workspaceFolder}/.examples/docker",
95-
"env": {
96-
"DOCKER_HOST": "unix:///run/docker.sock"
102+
"shell": {
103+
"executable": "bash",
104+
"args": ["-i", "-c"]
97105
}
98-
},
99-
"type": "shell"
106+
}
100107
},
101108
{
102109
"label": "Stop: all (docker)",
103110
"command": "docker compose --file docker-compose-local.yml down --remove-orphans",
111+
"type": "shell",
104112
"options": {
105113
"cwd": "${workspaceFolder}/.examples/docker",
106-
"env": {
107-
"DOCKER_HOST": "unix:///run/docker.sock"
114+
"shell": {
115+
"executable": "bash",
116+
"args": ["-i", "-c"]
108117
}
118+
}
119+
},
120+
// Logging (podman)
121+
{
122+
"label": "Logs: librebooking (podman)",
123+
"command": "journalctl --user -u app -f",
124+
"type": "shell",
125+
"presentation": {
126+
"reveal": "always",
127+
"panel": "new"
128+
}
129+
},
130+
{
131+
"label": "Logs: db (podman)",
132+
"command": "journalctl --user -u db -f",
133+
"type": "shell",
134+
"presentation": {
135+
"reveal": "always",
136+
"panel": "new"
137+
}
138+
},
139+
{
140+
"label": "Logs: cron (podman)",
141+
"command": "journalctl --user -u cron -f",
142+
"type": "shell",
143+
"presentation": {
144+
"reveal": "always",
145+
"panel": "new"
146+
}
147+
},
148+
{
149+
"label": "Logs:all",
150+
"dependsOn": [
151+
"Logs:librebooking",
152+
"Logs:db",
153+
],
154+
"presentation": {
155+
"reveal": "always",
156+
"panel": "dedicated"
109157
},
158+
"problemMatcher": []
159+
},
160+
{
161+
"label": "Status: all (podman)",
162+
"command": "systemctl --user status app db",
163+
"type": "shell",
164+
"presentation": {
165+
"reveal": "always",
166+
"panel": "new"
167+
}
168+
},
169+
// Booting (podman)
170+
{
171+
"label": "Restart: all (podman)",
172+
"command": "${workspaceFolder}/scripts/restart",
173+
"type": "shell",
174+
"options": {
175+
"cwd": "${workspaceFolder}/scripts"
176+
}
177+
},
178+
{
179+
"label": "Start: all (podman)",
180+
"command": "${workspaceFolder}/scripts/start",
110181
"type": "shell"
111-
}
182+
},
183+
{
184+
"label": "Stop: all (podman)",
185+
"command": "${workspaceFolder}/scripts/stop",
186+
"type": "shell"
187+
},
112188
]
113189
}

Dockerfile

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,20 @@ FROM composer:${VERSION_COMPOSER} AS comp
88
FROM alpine/git:${VERSION_GIT} AS upstream
99
ARG APP_GH_ADD_SHA=false
1010
ARG APP_GH_REF=refs/heads/develop
11-
ARG GIT_TREE=${APP_GH_REF##*/}
11+
ARG GIT_TREE
1212
ARG UPSTREAM_URL="https://github.com/librebooking/librebooking"
1313
WORKDIR /upstream
14-
RUN <<EORUN
15-
set -eux
16-
git clone ${UPSTREAM_URL} /upstream
17-
git checkout ${GIT_TREE}
18-
if [ "${APP_GH_ADD_SHA}" = "true" ]; then
19-
git describe --tags --long > config/custom-version.txt
20-
fi
21-
rm -rf .git
22-
EORUN
14+
15+
COPY --chmod=0755 scripts/clone.sh /usr/local/bin/clone.sh
16+
RUN APP_GH_ADD_SHA=${APP_GH_ADD_SHA} \
17+
APP_GH_REF=${APP_GH_REF} \
18+
GIT_TREE=${GIT_TREE} \
19+
UPSTREAM_URL=${UPSTREAM_URL} \
20+
/usr/local/bin/clone.sh
2321

2422
# Build supercronic
2523
FROM golang:trixie AS supercronic
26-
ADD https://github.com/aptible/supercronic.git#v0.2.44 /go/src/
27-
WORKDIR /go/src
28-
RUN <<EORUN
29-
set -eux
30-
go mod vendor
31-
go install
32-
EORUN
24+
RUN go install github.com/aptible/supercronic@v0.2.44
3325

3426
FROM php:${VERSION_PHP}-apache
3527
# Labels

0 commit comments

Comments
 (0)