Ссылка на коммит в подвале

Требует установку гит-хуков
master
Anthony Axenov 2022-09-12 22:34:05 +08:00
parent acf1f8083f
commit 585392b295
Signed by: anthony
GPG Key ID: EA9EC32FF7CCD4EC
8 changed files with 39 additions and 18 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
/.idea
/.vscode
/downloaded
/src/commit
/src/cache/*
/src/vendor
/src/views/custom/*

View File

@ -188,19 +188,12 @@ GET https://iptv.axenov.dev/<ID>/json
## Развёртывание проекта
### Aвтоматически
Локально достаточно выполнить `./iptv init && ./iptv open`.
Выполнить `./iptv init`
На сервере опционально можно настроить реверс-прокси до контейнера, например, чтобы настроить доступ по доменному
имени, изменить порт, подключить SSL-сертификаты или др.
### Вручную
1. Выполнить `cp ./src/.env.example ./src/.env`, установить необходимые параметры в файле `./src/.env`
2. Выполнить `docker compose up -d --build` (или `./iptv up`)
3. Открыть `http://<APP_URL>:8080` в браузере (или `./iptv open`)
Если на сервере, на котором запускаются контейнеры, стоит apache2, то его можно использовать как реверс прокси:
Для этого следует:
Если на сервере, на котором запускаются контейнеры, стоит apache2, то, чтобы использовать его как реверс-прокси, нужно:
```
$ sudo a2enmod proxy proxy_http proxy_balancer lbmethod_byrequests

View File

@ -32,7 +32,7 @@ services:
- ./log/nginx:/var/log/nginx:rw
- ./src:/var/www:ro
ports:
- 8080:80
- '8080:80'
links:
- php
depends_on:

View File

@ -0,0 +1,4 @@
#!/bin/bash
# хук пробрасывает хэш свежего коммита в контейнер
# для его отображения в подвале страницы
git rev-parse HEAD > src/commit

7
hooks/post-merge 100755
View File

@ -0,0 +1,7 @@
#!/bin/bash
# хук пробрасывает хэш свежего коммита в контейнер
# для его отображения в подвале страницы и очищает
# кеш шаблонов twig после слияния веток
# главным образом необходимо при git pull
git rev-parse HEAD > src/commit
docker exec -ti iptv-php rm -rf cache/views

15
iptv
View File

@ -15,15 +15,20 @@ open_browser() {
}
case "$1" in
'' | 'help' ) echo -e "Provide one of operations: \t init, start, stop, up, down, restart, rebuild, open";
'' | 'help' ) echo -e "Provide one of operations: \t init, start, stop, up, down, restart, rebuild, open, hooks";
echo "Otherwise all args will passed to 'docker exec -ti $CONTAINER ...'" ;;
'init' ) cp src/.env.example src/.env && nano src/.env && ./iptv up && ./iptv composer i && ./iptv open && echo -e "\nYou're welcome!\n\t$APP_URL";;
'init' ) cp src/.env.example src/.env && \
./iptv hooks && \
./iptv up && \
./iptv composer i && \
echo "Project started successfully! $APP_URL" ;;
'up' ) $CMD up -d --build && ./iptv open ;; # build and start containers
'down' ) $CMD down --remove-orphans ;; # stop and remove containers
'start' ) $CMD start && ./iptv open ;; # start containers
'start' ) $CMD start ;; # start containers
'stop' ) $CMD stop ;; # stop containers
'restart' ) $CMD stop && $CMD start ;; # restart containers
'rebuild' ) $CMD down --remove-orphans && $CMD up -d --build ;; # rebuild containers
'open' ) open_browser $APP_URL ;;
* ) docker exec -ti $CONTAINER $@ # exec anything else in container
'open' ) open_browser $APP_URL && echo -e "\nYou're welcome!\n\t$APP_URL" ;;
'hooks' ) ./hooks/post-commit && cp hooks/* .git/hooks ;;
* ) docker exec -ti $CONTAINER $* ;; # exec anything else in container
esac

View File

@ -13,6 +13,7 @@ class TwigFunctions extends AbstractExtension
{
return [
new TwigFunction('config', [$this, 'config']),
new TwigFunction('commit', [$this, 'commit']),
new TwigFunction('is_file', [$this, 'is_file']),
new TwigFunction('base_url', [$this, 'base_url']),
];
@ -23,6 +24,11 @@ class TwigFunctions extends AbstractExtension
return config($key, $default);
}
public function commit(): string
{
return file_get_contents(root_path('commit'));
}
public function base_url(string $path = ''): string
{
return base_url($path);

View File

@ -62,7 +62,12 @@
<a href="{{ base_url('faq') }}">FAQ</a>&nbsp;|&nbsp;<a
href="https://github.com/anthonyaxenov/iptv">GitHub</a>&nbsp;|&nbsp;<a
href="https://git.axenov.dev/anthony/iptv">Gitea</a>&nbsp;|&nbsp;<a
href="https://axenov.dev">axenov.dev</a>
href="https://axenov.dev">axenov.dev</a><br>
<span class="small text-muted">
commit&nbsp;<a class="text-muted" target="_blank"
href="https://github.com/anthonyaxenov/iptv/commit/{{ commit() }}"
>{{ commit()[:8] }}</a>
</span>
</footer>
</div>
{% if is_file("custom/custom.twig") %}