Rework #1

Open
JonatanRek wants to merge 31 commits from rework into dev
pull from: rework
37 changed files with 962 additions and 93 deletions

No files matched your search

-66
View File
@@ -1,66 +0,0 @@
name: "Build - Docker Image - RC"
run-name: ${{ gitea.actor }} is runs ci pipeline
on:
push:
branches:
- dev
schedule:
- cron: "0 1 * * *"
concurrency:
group: docker-build-dev
cancel-in-progress: true
jobs:
publish:
runs-on: ubuntu-latest
permissions:
packages: write
container:
image: catthehacker/ubuntu:act-latest
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v1
- uses: docker/login-action@v3
with:
registry: git.steelants.cz
username: ${{ secrets.GITEAUSER }}
password: ${{ secrets.GITEAPASSWD }}
- uses: docker/build-push-action@v6
with:
context: .
push: true
labels: |
org.steelants.image.traffic.version=${{ env.release_version }}
tags: git.steelants.cz/steelants/docker_php_base:dev
# ✅ Notifikace při úspěšném deploymentu
- name: Discord Webhook Success
if: success()
uses: tsickert/discord-webhook@v6.0.0
with:
webhook-url: ${{ secrets.WEBHOOK_URL }}
content: |
✅ Build successful!
Repo: ${{ github.repository }}
Branch: ${{ github.ref_name }}
Commit: ${{ github.sha }}
Version: ${{ env.release_version }}
# ❌ Notifikace při neúspěšném deploymentu
- name: Discord Webhook Failure
if: failure()
uses: tsickert/discord-webhook@v6.0.0
with:
webhook-url: ${{ secrets.WEBHOOK_URL }}
content: |
❌ Build failed!
Repo: ${{ github.repository }}
Branch: ${{ github.ref_name }}
Commit: ${{ github.sha }}
Version: ${{ env.release_version }}
+257 -17
View File
@@ -5,62 +5,302 @@ on:
push:
branches:
- main
schedule:
- cron: "0 1 * * *"
workflow_dispatch:
concurrency:
group: docker-build-prod
cancel-in-progress: true
jobs:
publish:
# ─── APACHE ───────────────────────────────────────────────────────────────
build-apache-amd64:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
container:
image: catthehacker/ubuntu:act-latest
outputs:
digest: ${{ steps.build.outputs.digest }}
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v1
- uses: docker/login-action@v3
with:
registry: git.steelants.cz
username: ${{ secrets.GITEAUSER }}
password: ${{ secrets.GITEAPASSWD }}
- uses: docker/build-push-action@v6
- id: build
uses: docker/build-push-action@v6
with:
context: .
push: true
labels: |
org.steelants.image.traffic.version=${{ env.release_version }}
tags: git.steelants.cz/steelants/docker_php_base:latest
context: apache
platforms: linux/amd64
outputs: type=image,name=git.steelants.cz/steelants/docker_php_base,push-by-digest=true,name-canonical=true,push=true
build-apache-arm64:
runs-on: ubuntu-latest-arm
permissions:
contents: read
packages: write
container:
image: catthehacker/ubuntu:act-latest
outputs:
digest: ${{ steps.build.outputs.digest }}
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v1
- uses: docker/login-action@v3
with:
registry: git.steelants.cz
username: ${{ secrets.GITEAUSER }}
password: ${{ secrets.GITEAPASSWD }}
- id: build
uses: docker/build-push-action@v6
with:
context: apache
platforms: linux/arm64
outputs: type=image,name=git.steelants.cz/steelants/docker_php_base,push-by-digest=true,name-canonical=true,push=true
manifest-apache:
needs: [build-apache-amd64, build-apache-arm64]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
container:
image: catthehacker/ubuntu:act-latest
steps:
- uses: docker/setup-buildx-action@v1
with:
driver: docker
- uses: docker/login-action@v3
with:
registry: git.steelants.cz
username: ${{ secrets.GITEAUSER }}
password: ${{ secrets.GITEAPASSWD }}
- name: Create and push multi-arch manifest
run: |
docker buildx imagetools create -t git.steelants.cz/steelants/docker_php_base:latest \
git.steelants.cz/steelants/docker_php_base@${{ needs.build-apache-amd64.outputs.digest }} \
git.steelants.cz/steelants/docker_php_base@${{ needs.build-apache-arm64.outputs.digest }}
# ✅ Notifikace při úspěšném deploymentu
- name: Discord Webhook Success
if: success()
uses: tsickert/discord-webhook@v6.0.0
with:
webhook-url: ${{ secrets.WEBHOOK_URL }}
content: |
✅ Build successful!
✅ APACHE - Build successful! (amd64 + arm64)
Repo: ${{ github.repository }}
Branch: ${{ github.ref_name }}
Commit: ${{ github.sha }}
Version: ${{ env.release_version }}
# ❌ Notifikace při neúspěšném deploymentu
- name: Discord Webhook Failure
if: failure()
uses: tsickert/discord-webhook@v6.0.0
with:
webhook-url: ${{ secrets.WEBHOOK_URL }}
content: |
❌ Build failed!
❌ APACHE - Build failed!
Repo: ${{ github.repository }}
Branch: ${{ github.ref_name }}
Commit: ${{ github.sha }}
# ─── APACHE V2 ────────────────────────────────────────────────────────
build-apache-v2-amd64:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
container:
image: catthehacker/ubuntu:act-latest
outputs:
digest: ${{ steps.build.outputs.digest }}
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v1
- uses: docker/login-action@v3
with:
registry: git.steelants.cz
username: ${{ secrets.GITEAUSER }}
password: ${{ secrets.GITEAPASSWD }}
- id: build
uses: docker/build-push-action@v6
with:
context: v2-apache
platforms: linux/amd64
outputs: type=image,name=git.steelants.cz/steelants/docker_php_base,push-by-digest=true,name-canonical=true,push=true
build-apache-v2-arm64:
runs-on: ubuntu-latest-arm
permissions:
contents: read
packages: write
container:
image: catthehacker/ubuntu:act-latest
outputs:
digest: ${{ steps.build.outputs.digest }}
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v1
- uses: docker/login-action@v3
with:
registry: git.steelants.cz
username: ${{ secrets.GITEAUSER }}
password: ${{ secrets.GITEAPASSWD }}
- id: build
uses: docker/build-push-action@v6
with:
context: v2-apache
platforms: linux/arm64
outputs: type=image,name=git.steelants.cz/steelants/docker_php_base,push-by-digest=true,name-canonical=true,push=true
manifest-apache-v2:
needs: [build-apache-v2-amd64, build-apache-v2-arm64]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
container:
image: catthehacker/ubuntu:act-latest
steps:
- uses: docker/setup-buildx-action@v1
with:
driver: docker
- uses: docker/login-action@v3
with:
registry: git.steelants.cz
username: ${{ secrets.GITEAUSER }}
password: ${{ secrets.GITEAPASSWD }}
- name: Create and push multi-arch manifest
run: |
docker buildx imagetools create -t git.steelants.cz/steelants/docker_php_base:v2-latest \
git.steelants.cz/steelants/docker_php_base@${{ needs.build-apache-v2-amd64.outputs.digest }} \
git.steelants.cz/steelants/docker_php_base@${{ needs.build-apache-v2-arm64.outputs.digest }}
- name: Discord Webhook Success
if: success()
uses: tsickert/discord-webhook@v6.0.0
with:
webhook-url: ${{ secrets.WEBHOOK_URL }}
content: |
✅ APACHE V2 - Build successful! (amd64 + arm64)
Repo: ${{ github.repository }}
Branch: ${{ github.ref_name }}
Commit: ${{ github.sha }}
- name: Discord Webhook Failure
if: failure()
uses: tsickert/discord-webhook@v6.0.0
with:
webhook-url: ${{ secrets.WEBHOOK_URL }}
content: |
❌ APACHE V2 - Build failed!
Repo: ${{ github.repository }}
Branch: ${{ github.ref_name }}
Commit: ${{ github.sha }}
# ─── ALPINE V2 ────────────────────────────────────────────────────────
build-alpine-v2-amd64:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
container:
image: catthehacker/ubuntu:act-latest
outputs:
digest: ${{ steps.build.outputs.digest }}
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v1
- uses: docker/login-action@v3
with:
registry: git.steelants.cz
username: ${{ secrets.GITEAUSER }}
password: ${{ secrets.GITEAPASSWD }}
- id: build
uses: docker/build-push-action@v6
with:
context: v2-fmp-alpine
platforms: linux/amd64
outputs: type=image,name=git.steelants.cz/steelants/docker_php_base,push-by-digest=true,name-canonical=true,push=true
build-alpine-v2-arm64:
runs-on: ubuntu-latest-arm
permissions:
contents: read
packages: write
container:
image: catthehacker/ubuntu:act-latest
outputs:
digest: ${{ steps.build.outputs.digest }}
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v1
- uses: docker/login-action@v3
with:
registry: git.steelants.cz
username: ${{ secrets.GITEAUSER }}
password: ${{ secrets.GITEAPASSWD }}
- id: build
uses: docker/build-push-action@v6
with:
context: v2-fmp-alpine
platforms: linux/arm64
outputs: type=image,name=git.steelants.cz/steelants/docker_php_base,push-by-digest=true,name-canonical=true,push=true
manifest-alpine-v2:
needs: [build-alpine-v2-amd64, build-alpine-v2-arm64]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
container:
image: catthehacker/ubuntu:act-latest
steps:
- uses: docker/setup-buildx-action@v1
with:
driver: docker
- uses: docker/login-action@v3
with:
registry: git.steelants.cz
username: ${{ secrets.GITEAUSER }}
password: ${{ secrets.GITEAPASSWD }}
- name: Create and push multi-arch manifest
run: |
docker buildx imagetools create -t git.steelants.cz/steelants/docker_php_base:alpine-v2-latest \
git.steelants.cz/steelants/docker_php_base@${{ needs.build-alpine-v2-amd64.outputs.digest }} \
git.steelants.cz/steelants/docker_php_base@${{ needs.build-alpine-v2-arm64.outputs.digest }}
- name: Discord Webhook Success
if: success()
uses: tsickert/discord-webhook@v6.0.0
with:
webhook-url: ${{ secrets.WEBHOOK_URL }}
content: |
✅ ALPINE V2 - Build successful! (amd64 + arm64)
Repo: ${{ github.repository }}
Branch: ${{ github.ref_name }}
Commit: ${{ github.sha }}
- name: Discord Webhook Failure
if: failure()
uses: tsickert/discord-webhook@v6.0.0
with:
webhook-url: ${{ secrets.WEBHOOK_URL }}
content: |
❌ ALPINE V2 - Build failed!
Repo: ${{ github.repository }}
Branch: ${{ github.ref_name }}
Commit: ${{ github.sha }}
Version: ${{ env.release_version }}
+1
View File
@@ -0,0 +1 @@
.megamemory/*
+127
View File
@@ -0,0 +1,127 @@
# docker_php_base
Základní Docker image pro Laravel aplikace (PHP 8.4). Registr: `git.steelants.cz/steelants/docker_php_base`.
Všechny image se buildují pro `linux/amd64` a `linux/arm64` (multi-arch manifest) workflow [`.gitea/workflows/docker-build.yaml`](.gitea/workflows/docker-build.yaml) při push do `main`, každou noc v 1:00 a ručně.
## Přehled image
| Tag | Zdrojová složka | Základ | Web server | Stav |
|---|---|---|---|---|
| `latest` | [`apache/`](apache/) | `php:8.4-apache` | Apache (`mod_rewrite`) | původní verze (v1), beze změny |
| `v2-latest` | [`v2-apache/`](v2-apache/) | `php:8.4-apache` | Apache (`mod_rewrite`) | nová verze (v2) |
| `alpine-v2-latest` | [`v2-fmp-alpine/`](v2-fmp-alpine/) | `php:8.4-fpm-alpine` | žádný (jen PHP-FPM) | nová verze (v2), v produkci se nepoužívá |
Společné pro všechny image:
- PHP rozšíření: `pdo_mysql`, `pgsql`, `pdo_pgsql`, `zip`, `opcache`, `pcntl`, `sockets`, `bcmath`, `soap`, `gd` (freetype, jpeg, webp), `intl`, `calendar`, `imagick` (s rsvg). Build selže, když `imagick` nebo `gd` nemají podporu JPEG.
- Nástroje: `composer`, `git`, `node` + `npm`, `supervisor`, klienti `mysql` a `psql`.
- Časová zóna `Europe/Prague`, `COMPOSER_ALLOW_SUPERUSER=1`.
- Kořen aplikace `APP_ROOT=/var/www/html`.
- `memory_limit=256M`, `upload_max_filesize` a `post_max_size` `100M`, opcache (`PHP_OPCACHE_*`).
- Apache image: document root `APACHE_DOCUMENT_ROOT=${APP_ROOT}/public` (jde přepsat přes `-e`).
## v1: `latest` (složka `apache/`)
Původní chování, nic se nemění:
- Supervisor konfigurace je statická: `supervisor/supervisord.conf` (`nodaemon=true`, `include conf.d/*.conf`) a `supervisor/conf.d/laravel-queues.conf` (queue workery `default,importstatistics`, `statistics`, `detections`).
- Scheduler běží přes **cron**: `* * * * * www-data cd /var/www/html && php artisan schedule:run`, cron se spouští v `apache2-foreground`.
- Supervisor se sám **nespouští**. Aplikace ho spouští ze svého `start.sh` (`supervisord -n &`).
- Žádné skripty při startu. Veškeré nastavení (`.env`, composer, migrace, cache) dělá `start.sh` aplikace.
## v2: `v2-latest` a `alpine-v2-latest`
V2 přesouvá obecné kroky ze `start.sh` aplikace do základního image. Obě v2 varianty mají stejnou strukturu i stejné skripty (`entrypoint.d/`, `supervisor.d/`).
### Jak se spouští
1. Původní příkaz kontejneru (`apache2-foreground`, resp. `docker-php-entrypoint php-fpm`) je upravený: těsně před `exec` volá [`entrypoint-runner.sh`](v2-apache/entrypoint-runner.sh).
2. Runner spustí **v abecedním pořadí všechny spustitelné `/etc/entrypoint.d/*.sh`**. Každý běží jako samostatný proces (proměnné se mezi skripty nepředávají).
3. **Selže-li skript, start se zastaví** (`entrypoint script failed: <skript>`, kontejner skončí). Ostatní skripty ani web server se nespustí.
4. **Zpětná kompatibilita:** pokud v kořeni aplikace existuje `start.sh` (`$APP_ROOT/start.sh`), runner se přeskočí a `entrypoint.d` se nespustí. Image se starým `start.sh` tak nedostane nové skripty.
5. Pro alpine image platí totéž, jen runner běží ze stock `docker-php-entrypoint`, takže projde každý příkaz (i `docker run image php -v`). Skripty v kontejneru bez aplikace (bez `artisan`, `composer.json`) proto končí kódem 0.
### Skripty v `/etc/entrypoint.d/` (pořadí spouštění)
| Skript | Co dělá | Poznámka |
|---|---|---|
| `05-permissions.sh` | `chown -R www-data:www-data` na `storage` a `bootstrap/cache`, jen když je vlastník horní složky jiný | namountované volume bývá root-owned |
| `10-opcache.sh` | `APP_DEBUG=false` → nastaví `opcache.validate_timestamps=${PHP_OPCACHE_VALIDATE_TIMESTAMPS:-1}`; jinak (i když `APP_DEBUG` není nastavené) → `opcache.enable=0` | upravuje `*opcache.ini` v `$PHP_INI_DIR/conf.d` |
| `15-composer.sh` | bez `composer.json` nic; jinak `composer install --prefer-dist --optimize-autoloader` (s dev závislostmi při `APP_DEBUG=true`), jinak s `--no-dev` | běží při **každém** startu, vyžaduje síť. `$init` se nepředává, rozhoduje jen `APP_DEBUG` |
| `20-env.sh` | existuje `/config/.env` → zkopíruje ho do `.env`; jinak, chybí-li `.env` a je `.env.example`, vytvoří `.env` z příkladu a uloží do `/config/.env` | jen s `artisan`, `/config` je vždy volume |
| `25-key.sh` | `php artisan key:generate --force --no-interaction` jen když `APP_KEY` není v prostředí ani v `.env`; vygenerovaný `.env` uloží do `/config/.env` | existující klíč nikdy nepřepíše |
| `26-cache.sh` | `cache:clear`, `config:clear`, `route:clear`, `view:clear` | jen s `artisan`. Při `CACHE_STORE=database` běží před migracemi |
| `27-sqlite.sh` | je-li sqlite (`DB_CONNECTION=sqlite` v `.env` i v prostředí), vytvoří prázdný `database/database.sqlite` | složka `database/` musí existovat |
| `30-storage.sh` | `php artisan storage:link` | jen s `artisan` |
| `35-migrate.sh` | `php artisan migrate --force --no-interaction` | běží při **každém** startu každého kontejneru, tedy i workerů a replik |
| `90-supervisord.sh` | zapíše `/etc/supervisor/supervisord.conf` (`nodaemon=true`, `include /etc/supervisor/conf.d/*.conf`) a spustí `supervisord` na pozadí | |
Vlastní skript aplikace přidáš do `/etc/entrypoint.d/` s vhodným číslem (soubor musí končit `.sh`, být spustitelný a používat `#!/bin/sh`). Chceš-li skript vypnout, smaž ho (`RUN rm /etc/entrypoint.d/35-migrate.sh`).
### Supervisor (`/etc/supervisor/conf.d/`)
Soubory ze složky `supervisor.d/` se kopírují do `/etc/supervisor/conf.d/` a supervisor načte všechny `*.conf`:
- `laravel-queues.conf`: tři queue workery (`default,importstatistics`, `statistics`, `detections`), `user=www-data`, `autorestart`.
- `laravel-scheduler.conf`: `php artisan schedule:work` (vyžaduje Laravel 8+). **Nahrazuje cron**, ten v2 neobsahuje.
- `reverb.conf.example`: příklad programu `reverb:start --host=0.0.0.0 --no-interaction --debug`. Nenačítá se (přípona `.example`). Zapneš ho tak, že ho zkopíruješ jako `reverb.conf`.
Cesty ke `artisan` se berou z `%(ENV_APP_ROOT)s`. Programy lze přidat nebo přepsat vlastními soubory v `conf.d`.
### Volume
- `/config`: perzistentní `.env` a `APP_KEY` (viz `20-env.sh`, `25-key.sh`). Bez připojeného volume se `.env` a vygenerovaný klíč ztratí při novém kontejneru. Spolehlivější je nastavit `APP_KEY` jako proměnnou prostředí.
- `storage/app` volume si deklaruje aplikace sama.
### Proměnné prostředí
| Proměnná | Výchozí | Význam |
|---|---|---|
| `APP_ROOT` | `/var/www/html` | kořen aplikace (skripty, supervisor) |
| `APACHE_DOCUMENT_ROOT` | `${APP_ROOT}/public` | document root (jen apache) |
| `APP_DEBUG` | nenastaveno | řídí opcache a typ `composer install` |
| `PHP_OPCACHE_VALIDATE_TIMESTAMPS` | `1` | použije se při `APP_DEBUG=false` |
| `PHP_OPCACHE_*` | viz Dockerfile | velikosti opcache |
| `APP_KEY` | nenastaveno | je-li nastavená, klíč se negeneruje |
| `DB_CONNECTION` | nenastaveno | spouští přípravu sqlite (`27-sqlite.sh`) |
### Rozdíly mezi `v2-latest` (apache) a `alpine-v2-latest`
Chování je záměrně stejné: stejné výchozí proměnné prostředí, stejné `php.ini` (`memory_limit=256M`, `upload_max_filesize=100M`, `post_max_size=100M`, časová zóna), stejný `opcache.ini`, stejné skripty v `entrypoint.d/` a stejné supervisor programy. Liší se jen to, co vyplývá z technologie:
- Alpine je PHP-FPM bez web serveru, před něj musí přijít vlastní web server (např. nginx). Nemá `mod_rewrite` ani `APACHE_DOCUMENT_ROOT`.
- Runner běží z jiného místa: apache v `apache2-foreground`, alpine ve stock `docker-php-entrypoint` (projde tedy každý příkaz, i `docker run image php -v`).
- Alpine je postavený na musl a `apk`, apache na Debianu a `apt`. Verze `node`, `git` a klientů se mohou lišit. Composer se do alpine kopíruje z image `composer:2`.
- Apache image navíc zapisuje `printenv` do `/etc/environment` (zbytek po cronu z v1, ve v2 není potřeba).
- Alpine image se v produkci nepoužívá, byl ověřen jen testy na atrapě `artisan`.
## Migrace aplikace na v2 (podklad pro AI)
Postup pro aplikaci, která dnes dědí z `docker_php_base:latest` a má vlastní `start.sh` s `CMD ["/var/www/html/start.sh"]`:
1. V `Dockerfile` změň `FROM` na `git.steelants.cz/steelants/docker_php_base:v2-latest`.
2. Smaž `start.sh` a řádky `RUN chmod +x /var/www/html/start.sh` a `CMD ["/var/www/html/start.sh"]`. Výchozí příkaz `apache2-foreground` už spouští `entrypoint.d`. Dokud `start.sh` v `APP_ROOT` existuje, v2 skripty se nespustí.
3. Smaž z `Dockerfile` to, co už je v základu: `RUN mkdir -p /config`, `VOLUME /config` a `docker-php-ext-install calendar` (`calendar` je v základu). `VOLUME` pro `storage/app` nech v aplikaci.
4. Z původního `start.sh` už jsou v základu: příprava `.env` z `/config`, generování `APP_KEY`, sqlite, `composer install`, `storage:link`, `migrate`, `*:clear`, úprava opcache a spuštění supervisoru.
5. V základu **není**: `config:cache`, `route:cache`, `view:cache` pro produkci, a `init` (rozlišení prvního startu pro composer). Pokud je aplikace potřebuje, přidej vlastní skript, např. `entrypoint.d/50-optimize.sh` (běží po `26-cache.sh`), a zkopíruj ho `COPY --chmod=755 entrypoint.d/ /etc/entrypoint.d/`.
6. Reverb (`php artisan reverb:start ... &` v `start.sh`) nahraď souborem `/etc/supervisor/conf.d/reverb.conf` (zkopíruj z `reverb.conf.example`). Řádek se `&` ze `start.sh` odstraň, jinak poběží dvakrát.
7. Odstraň ze `start.sh`/Dockeru vlastní spouštění `supervisord`. `90-supervisord.sh` ho spouští sám, dva supervisory by znamenaly duplicitní workery i scheduler.
8. Cron už v základu není a scheduler běží přes supervisor (`schedule:work`, Laravel 8+). Aplikace, která dřív spoléhala na cron z `latest` a nespouštěla supervisor, scheduler při přechodu ztratí.
Na co si dát při migraci pozor:
- Skripty jsou **fail-fast**. Chyba migrace, composeru nebo `cache:clear` zastaví start kontejneru.
- Migrace běží při každém startu každého kontejneru. U více replik se mohou přetahovat o zámek.
- `composer install` běží při každém startu a potřebuje síť. Pokud je `vendor` hotový v buildu, zvaž smazání `15-composer.sh`.
- `10-opcache.sh` vypíná opcache i tehdy, když `APP_DEBUG` není nastavené. Nastav `APP_DEBUG=false`, chceš-li opcache v produkci.
- Skripty byly ověřeny na atrapě `artisan` a prázdném projektu, ne na plné Laravel aplikaci.
## Ruční build
```bash
docker build --platform linux/arm/v7,linux/arm64/v8,linux/amd64 -t git.steelants.cz/steelants/docker_php_base:latest ./apache
docker build -t git.steelants.cz/steelants/docker_php_base:v2-latest ./v2-apache
docker build -t git.steelants.cz/steelants/docker_php_base:alpine-v2-latest ./v2-fmp-alpine
docker push git.steelants.cz/steelants/docker_php_base:latest
```
+33 -7
View File
@@ -1,9 +1,12 @@
# Use PHP with Apache as the base image
FROM php:8.4-apache
# Application root (default keeps the original /var/www/html layout)
ENV APP_ROOT="/var/www/html"
# Environment
ENV TZ="Europe/Prague" \
APACHE_DOCUMENT_ROOT="/var/www/html/public" \
APACHE_DOCUMENT_ROOT="${APP_ROOT}/public" \
PHP_INI_FILE="$PHP_INI_DIR/php.ini" \
PHP_OPCACHE_VALIDATE_TIMESTAMPS="1" \
PHP_OPCACHE_MAX_ACCELERATED_FILES="10000" \
@@ -23,6 +26,13 @@ RUN --mount=type=cache,target=/var/cache/apt \
libzip-dev \
zip \
unzip \
zlib1g-dev \
libicu-dev \
libjpeg-dev \
libpng-dev \
libwebp-dev \
libfreetype6-dev \
g++ \
nodejs \
npm \
cron \
@@ -51,7 +61,14 @@ RUN --mount=type=cache,target=/var/cache/apt \
# Enable Apache mod_rewrite for URL rewriting
RUN a2enmod rewrite
RUN docker-php-ext-configure intl
RUN docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp
# Install PHP extensions
RUN docker-php-ext-configure \
opcache --enable-opcache
RUN docker-php-ext-install \
pdo_mysql \
pgsql \
@@ -62,9 +79,17 @@ RUN docker-php-ext-install \
sockets\
bcmath \
soap \
gd
gd \
intl \
calendar
RUN docker-php-ext-enable imagick
RUN docker-php-ext-enable \
imagick \
opcache
# Fail fast if the JPEG delegate did not make it into the image
RUN php -r 'if (!in_array("JPEG", Imagick::queryFormats())) { fwrite(STDERR, "ERROR: imagick built without JPEG delegate\n"); exit(1); } echo "imagick JPEG delegate OK\n";' && \
php -r 'if (!function_exists("imagecreatefromjpeg")) { fwrite(STDERR, "ERROR: gd built without JPEG support\n"); exit(1); } echo "gd JPEG OK\n";'
# PHP
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_FILE" && \
@@ -74,7 +99,7 @@ RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_FILE" && \
printf '[Date]\ndate.timezone="%s"\n', $TZ > "$PHP_INI_DIR/conf.d/tzone.ini"
#OPCACHE
RUN echo '\n\
RUN echo "\n\
[opcache]\n\
opcache.enable=1\n\
opcache.revalidate_freq=0\n\
@@ -83,15 +108,16 @@ opcache.max_accelerated_files=${PHP_OPCACHE_MAX_ACCELERATED_FILES}\n\
opcache.memory_consumption=${PHP_OPCACHE_MEMORY_CONSUMPTION}\n\
opcache.max_wasted_percentage=${PHP_OPCACHE_MAX_WASTED_PERCENTAGE}\n\
opcache.interned_strings_buffer=16\n\
opcache.fast_shutdown=1' >> "$PHP_INI_DIR/conf.d/opcache.ini"
opcache.fast_shutdown=1" >> "$PHP_INI_DIR/conf.d/opcache.ini"
#SUPERVISORD
RUN mkdir -p /var/log/supervisor
COPY supervisor/ /etc/supervisor/
COPY ./supervisor/supervisord.conf /etc/supervisor/supervisord.conf
COPY ./supervisor/conf.d/laravel-queues.conf /etc/supervisor/conf.d/laravel-queues.conf
# Setup Crone
RUN mkdir -p /var/log/cron && \
echo "* * * * * www-data cd /var/www/html && /usr/local/bin/php artisan schedule:run >> /dev/null 2>&1" >> /etc/crontab
echo "* * * * * www-data cd ${APP_ROOT} && /usr/local/bin/php artisan schedule:run >> /dev/null 2>&1" >> /etc/crontab
# Install composer # bun
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
@@ -1,19 +1,19 @@
[program:queue-default]
command=/usr/local/bin/php /var/www/html/artisan queue:work --queue=default,importstatistics
command=/usr/local/bin/php %(ENV_APP_ROOT)s/artisan queue:work --sleep=3 --tries=3 --queue=default,importstatistics
user=www-data
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/queue-default.log
[program:queue-statistics]
command=/usr/local/bin/php /var/www/html/artisan queue:work --queue=statistics
command=/usr/local/bin/php %(ENV_APP_ROOT)s/artisan queue:work --sleep=5 --tries=3 --queue=statistics
user=www-data
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/queue-statistics.log
[program:queue-detections]
command=/usr/local/bin/php /var/www/html/artisan queue:work --queue=detections
command=/usr/local/bin/php %(ENV_APP_ROOT)s/artisan queue:work --sleep=3 --tries=3 --queue=detections
user=www-data
autostart=true
autorestart=true
File renamed without changes.
+140
View File
@@ -0,0 +1,140 @@
# Use PHP with Apache as the base image
FROM php:8.4-apache
# Application root (default keeps the original /var/www/html layout)
ENV APP_ROOT="/var/www/html"
# Environment
ENV TZ="Europe/Prague" \
APACHE_DOCUMENT_ROOT="${APP_ROOT}/public" \
PHP_INI_FILE="$PHP_INI_DIR/php.ini" \
PHP_OPCACHE_VALIDATE_TIMESTAMPS="1" \
PHP_OPCACHE_MAX_ACCELERATED_FILES="10000" \
PHP_OPCACHE_MEMORY_CONSUMPTION="192" \
PHP_OPCACHE_MAX_WASTED_PERCENTAGE="10" \
COMPOSER_ALLOW_SUPERUSER=1
# Timezone
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# Install Additional System Dependencies
RUN rm -f /etc/apt/apt.conf.d/docker-clean
RUN --mount=type=cache,target=/var/cache/apt \
apt-get update && apt-get install -yqq --no-install-recommends \
git \
libpq-dev \
libzip-dev \
zip \
unzip \
zlib1g-dev \
libicu-dev \
libjpeg-dev \
libpng-dev \
libwebp-dev \
libfreetype6-dev \
g++ \
nodejs \
npm \
cron \
nano \
default-mysql-client \
postgresql-client \
imagemagick \
libmagickwand-dev \
librsvg2-2 \
librsvg2-dev \
librsvg2-bin \
supervisor && \
git clone https://github.com/Imagick/imagick --depth 1 /tmp/imagick && \
cd /tmp/imagick && \
phpize && \
./configure --with-rsvg && \
ldconfig && \
make && \
make install && \
apt-get autoremove && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
npm config set cache /tmp --global && \
mkdir -p /var/log/supervisor
# Enable Apache mod_rewrite for URL rewriting
RUN a2enmod rewrite
RUN docker-php-ext-configure intl
RUN docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp
# Install PHP extensions
RUN docker-php-ext-configure \
opcache --enable-opcache
RUN docker-php-ext-install \
pdo_mysql \
pgsql \
pdo_pgsql \
zip \
opcache \
pcntl \
sockets\
bcmath \
soap \
gd \
intl \
calendar
RUN docker-php-ext-enable \
imagick \
opcache
# Fail fast if the JPEG delegate did not make it into the image
RUN php -r 'if (!in_array("JPEG", Imagick::queryFormats())) { fwrite(STDERR, "ERROR: imagick built without JPEG delegate\n"); exit(1); } echo "imagick JPEG delegate OK\n";' && \
php -r 'if (!function_exists("imagecreatefromjpeg")) { fwrite(STDERR, "ERROR: gd built without JPEG support\n"); exit(1); } echo "gd JPEG OK\n";'
# PHP
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_FILE" && \
sed -i "s|memory_limit = 128M|memory_limit = 256M |g" "$PHP_INI_FILE" && \
sed -i "s|upload_max_filesize = 2M|upload_max_filesize = 100M |g" "$PHP_INI_FILE" && \
sed -i "s|post_max_size = 8M|post_max_size = 100M |g" "$PHP_INI_FILE" && \
printf '[Date]\ndate.timezone="%s"\n', $TZ > "$PHP_INI_DIR/conf.d/tzone.ini"
#OPCACHE
RUN echo "\n\
[opcache]\n\
opcache.enable=1\n\
opcache.revalidate_freq=0\n\
opcache.validate_timestamps=${PHP_OPCACHE_VALIDATE_TIMESTAMPS}\n\
opcache.max_accelerated_files=${PHP_OPCACHE_MAX_ACCELERATED_FILES}\n\
opcache.memory_consumption=${PHP_OPCACHE_MEMORY_CONSUMPTION}\n\
opcache.max_wasted_percentage=${PHP_OPCACHE_MAX_WASTED_PERCENTAGE}\n\
opcache.interned_strings_buffer=16\n\
opcache.fast_shutdown=1" >> "$PHP_INI_DIR/conf.d/opcache.ini"
#SUPERVISORD
RUN mkdir -p /var/log/supervisor
COPY ./supervisor.d/ /etc/supervisor/conf.d/
#ENTRYPOINTS
COPY --chmod=755 ./entrypoint.d/ /etc/entrypoint.d/
COPY --chmod=755 ./entrypoint-runner.sh /usr/local/bin/entrypoint-runner.sh
# Persistent .env storage (see entrypoint.d/20-env.sh)
RUN mkdir -p /config
VOLUME /config
# Install composer # bun
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Configure Apache DocumentRoot to point to Laravel's public directory
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf && \
sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf && \
sed -i 's/^exec /printenv > \/etc\/environment\n\nexec /' /usr/local/bin/apache2-foreground && \
sed -i 's#^exec #entrypoint-runner.sh\n\nexec #' /usr/local/bin/apache2-foreground
#Cleaning
RUN apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /var/cache/apt/* && \
rm -rf /usr/share/man/* && \
rm -rf /usr/share/doc/* && \
rm -rf /tmp/*
+9
View File
@@ -0,0 +1,9 @@
#!/bin/sh
# Legacy images ship their own start.sh in the app root and do the whole setup themselves.
[ -f "${APP_ROOT:-/var/www/html}/start.sh" ] && exit 0
for f in /etc/entrypoint.d/*.sh; do
if [ -x "$f" ]; then
"$f" || { echo "entrypoint script failed: $f" >&2; exit 1; }
fi
done
+10
View File
@@ -0,0 +1,10 @@
#!/bin/sh
# Mounted volumes are usually root-owned, so www-data could not write into storage and bootstrap/cache.
cd "${APP_ROOT:-/var/www/html}" || exit 0
for dir in storage bootstrap/cache; do
if [ -d "$dir" ] && [ "$(stat -c %U "$dir")" != "www-data" ]; then
chown -R www-data:www-data "$dir"
fi
done
exit 0
+8
View File
@@ -0,0 +1,8 @@
#!/bin/sh
for ini in "${PHP_INI_DIR}"/conf.d/*opcache.ini; do
if [ "$(echo "$APP_DEBUG" | tr '[:upper:]' '[:lower:]')" = "false" ]; then
sed -ri -e "s!opcache.validate_timestamps=.*!opcache.validate_timestamps=${PHP_OPCACHE_VALIDATE_TIMESTAMPS:-1}!g" "$ini"
else
sed -ri -e 's!opcache.enable=1!opcache.enable=0!g' "$ini"
fi
done
+11
View File
@@ -0,0 +1,11 @@
#!/bin/sh
# Composer dependencies
[ -f composer.json ] || exit 0
if [ "$init" = "true" ] || [ "$(echo "$APP_DEBUG" | tr '[:upper:]' '[:lower:]')" = "true" ]; then
echo "Initial setup nebo debug mód - instalace Composeru s dev závislostmi"
composer install --prefer-dist --optimize-autoloader
else
echo "Produkční instalace - Composer bez dev závislostí"
composer install --prefer-dist --no-dev --optimize-autoloader
fi
+17
View File
@@ -0,0 +1,17 @@
#!/bin/sh
# Prepares .env. When /config is mounted, .env is restored from /config/.env and saved there on first creation.
cd "${APP_ROOT:-/var/www/html}" || exit 0
[ -f artisan ] || exit 0
if [ -d /config ] && [ -f /config/.env ]; then
echo "Using existing /config/.env"
cp /config/.env .env
elif [ ! -f .env ] && [ -f .env.example ]; then
echo "Creating .env from example"
cp .env.example .env
chown "$(stat -c %u:%g .env.example)" .env
if [ -d /config ]; then
cp .env /config/.env
fi
fi
+14
View File
@@ -0,0 +1,14 @@
#!/bin/sh
# Generates APP_KEY only when none exists yet (env or .env), so an existing key is never rotated.
cd "${APP_ROOT:-/var/www/html}" || exit 0
[ -f artisan ] || exit 0
[ -f .env ] || exit 0
[ -n "$APP_KEY" ] && exit 0
if ! grep -Eq '^APP_KEY=.+' .env; then
echo "Generating application key"
php artisan key:generate --force --no-interaction
[ -d /config ] && cp .env /config/.env
fi
exit 0
+9
View File
@@ -0,0 +1,9 @@
#!/bin/sh
# Clear Laravel caches
[ -f artisan ] || exit 0
echo "Clearing Laravel caches"
php artisan cache:clear
php artisan config:clear
php artisan route:clear
php artisan view:clear
+8
View File
@@ -0,0 +1,8 @@
#!/bin/sh
# SQLite database initialization
if grep -iq "^DB_CONNECTION=sqlite" .env && [ "$DB_CONNECTION" = "sqlite" ]; then
if [ ! -f database/database.sqlite ]; then
echo "Creating empty SQLite database"
touch database/database.sqlite
fi
fi
+6
View File
@@ -0,0 +1,6 @@
#!/bin/sh
# Link storage and seed database if first init
[ -f artisan ] || exit 0
echo "Linking storage directory"
php artisan storage:link
+6
View File
@@ -0,0 +1,6 @@
#!/bin/sh
# Migrate database
[ -f artisan ] || exit 0
echo "Running database migrations"
php artisan migrate --force --no-interaction
+12
View File
@@ -0,0 +1,12 @@
#!/bin/sh
cat > /etc/supervisor/supervisord.conf <<'EOF'
[supervisord]
nodaemon=true
logfile=/var/log/supervisor/supervisord.log
[include]
files = /etc/supervisor/conf.d/*.conf
EOF
# nodaemon=true keeps supervisord in the foreground, so detach it here
supervisord -c /etc/supervisor/supervisord.conf &
@@ -0,0 +1,20 @@
[program:queue-default]
command=/usr/local/bin/php %(ENV_APP_ROOT)s/artisan queue:work --sleep=3 --tries=3 --queue=default,importstatistics
user=www-data
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/queue-default.log
[program:queue-statistics]
command=/usr/local/bin/php %(ENV_APP_ROOT)s/artisan queue:work --sleep=5 --tries=3 --queue=statistics
user=www-data
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/queue-statistics.log
[program:queue-detections]
command=/usr/local/bin/php %(ENV_APP_ROOT)s/artisan queue:work --sleep=3 --tries=3 --queue=detections
user=www-data
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/queue-detections.log
@@ -0,0 +1,6 @@
[program:scheduler]
command=/usr/local/bin/php %(ENV_APP_ROOT)s/artisan schedule:work
user=www-data
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/scheduler.log
@@ -0,0 +1,8 @@
; Example only, not loaded (supervisor includes just *.conf).
; To enable it, copy it to /etc/supervisor/conf.d/reverb.conf (or rename it to reverb.conf in supervisor.d).
[program:reverb]
command=/usr/local/bin/php %(ENV_APP_ROOT)s/artisan reverb:start --host=0.0.0.0 --no-interaction --debug
user=www-data
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/reverb.log
+113
View File
@@ -0,0 +1,113 @@
FROM php:8.4-fpm-alpine
# Application root (same default as the apache image)
ENV APP_ROOT="/var/www/html"
ENV TZ="Europe/Prague" \
PHP_INI_FILE="$PHP_INI_DIR/php.ini" \
COMPOSER_ALLOW_SUPERUSER=1 \
PHP_OPCACHE_VALIDATE_TIMESTAMPS="1" \
PHP_OPCACHE_MAX_ACCELERATED_FILES="10000" \
PHP_OPCACHE_MEMORY_CONSUMPTION="192" \
PHP_OPCACHE_MAX_WASTED_PERCENTAGE="10"
RUN apk add --no-cache \
tzdata \
bash \
ca-certificates \
libpq \
libzip \
imagemagick \
imagemagick-dev \
librsvg \
freetype \
libjpeg-turbo \
libpng \
icu \
oniguruma \
libxml2 \
libwebp \
git \
nano \
zip \
unzip \
nodejs \
npm \
supervisor \
mysql-client \
postgresql-client
RUN apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS \
postgresql-dev \
libzip-dev \
freetype-dev \
libjpeg-turbo-dev \
libwebp-dev \
libpng-dev \
icu-dev \
libxml2-dev \
linux-headers
RUN docker-php-ext-configure \
gd --with-freetype --with-jpeg --with-webp \
&& docker-php-ext-install -j$(nproc) \
pdo_mysql \
pdo_pgsql \
pgsql \
zip \
bcmath \
soap \
gd \
intl \
opcache \
sockets \
pcntl \
calendar
RUN pecl install imagick \
&& docker-php-ext-enable imagick
RUN apk del .build-deps
# Fail fast if the JPEG delegate did not make it into the image
RUN php -r 'if (!in_array("JPEG", Imagick::queryFormats())) { fwrite(STDERR, "ERROR: imagick built without JPEG delegate\n"); exit(1); } echo "imagick JPEG delegate OK\n";' && \
php -r 'if (!function_exists("imagecreatefromjpeg")) { fwrite(STDERR, "ERROR: gd built without JPEG support\n"); exit(1); } echo "gd JPEG OK\n";'
# Composer
COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer
# PHP
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_FILE" && \
sed -i "s|memory_limit = 128M|memory_limit = 256M |g" "$PHP_INI_FILE" && \
sed -i "s|upload_max_filesize = 2M|upload_max_filesize = 100M |g" "$PHP_INI_FILE" && \
sed -i "s|post_max_size = 8M|post_max_size = 100M |g" "$PHP_INI_FILE" && \
printf '[Date]\ndate.timezone="%s"\n' "$TZ" > "$PHP_INI_DIR/conf.d/tzone.ini"
#OPCACHE
RUN { \
echo "[opcache]"; \
echo "opcache.enable=1"; \
echo "opcache.revalidate_freq=0"; \
echo "opcache.validate_timestamps=${PHP_OPCACHE_VALIDATE_TIMESTAMPS}"; \
echo "opcache.max_accelerated_files=${PHP_OPCACHE_MAX_ACCELERATED_FILES}"; \
echo "opcache.memory_consumption=${PHP_OPCACHE_MEMORY_CONSUMPTION}"; \
echo "opcache.max_wasted_percentage=${PHP_OPCACHE_MAX_WASTED_PERCENTAGE}"; \
echo "opcache.interned_strings_buffer=16"; \
echo "opcache.fast_shutdown=1"; \
} > "$PHP_INI_DIR/conf.d/opcache.ini"
# Supervisor (queue workers + scheduler, started from entrypoint.d/90-supervisord.sh)
RUN mkdir -p /var/log/supervisor
COPY ./supervisor.d/ /etc/supervisor/conf.d/
# Entrypoint scripts (run in order from the stock entrypoint)
COPY --chmod=755 ./entrypoint.d/ /etc/entrypoint.d/
COPY --chmod=755 ./entrypoint-runner.sh /usr/local/bin/entrypoint-runner.sh
# Persistent .env storage (see entrypoint.d/20-env.sh)
RUN mkdir -p /config
VOLUME /config
RUN sed -i 's#^exec #entrypoint-runner.sh\n\nexec #' /usr/local/bin/docker-php-entrypoint
WORKDIR ${APP_ROOT}
+9
View File
@@ -0,0 +1,9 @@
#!/bin/sh
# Legacy images ship their own start.sh in the app root and do the whole setup themselves.
[ -f "${APP_ROOT:-/var/www/html}/start.sh" ] && exit 0
for f in /etc/entrypoint.d/*.sh; do
if [ -x "$f" ]; then
"$f" || { echo "entrypoint script failed: $f" >&2; exit 1; }
fi
done
@@ -0,0 +1,10 @@
#!/bin/sh
# Mounted volumes are usually root-owned, so www-data could not write into storage and bootstrap/cache.
cd "${APP_ROOT:-/var/www/html}" || exit 0
for dir in storage bootstrap/cache; do
if [ -d "$dir" ] && [ "$(stat -c %U "$dir")" != "www-data" ]; then
chown -R www-data:www-data "$dir"
fi
done
exit 0
+8
View File
@@ -0,0 +1,8 @@
#!/bin/sh
for ini in "${PHP_INI_DIR}"/conf.d/*opcache.ini; do
if [ "$(echo "$APP_DEBUG" | tr '[:upper:]' '[:lower:]')" = "false" ]; then
sed -ri -e "s!opcache.validate_timestamps=.*!opcache.validate_timestamps=${PHP_OPCACHE_VALIDATE_TIMESTAMPS:-1}!g" "$ini"
else
sed -ri -e 's!opcache.enable=1!opcache.enable=0!g' "$ini"
fi
done
+11
View File
@@ -0,0 +1,11 @@
#!/bin/sh
# Composer dependencies
[ -f composer.json ] || exit 0
if [ "$init" = "true" ] || [ "$(echo "$APP_DEBUG" | tr '[:upper:]' '[:lower:]')" = "true" ]; then
echo "Initial setup nebo debug mód - instalace Composeru s dev závislostmi"
composer install --prefer-dist --optimize-autoloader
else
echo "Produkční instalace - Composer bez dev závislostí"
composer install --prefer-dist --no-dev --optimize-autoloader
fi
+17
View File
@@ -0,0 +1,17 @@
#!/bin/sh
# Prepares .env. When /config is mounted, .env is restored from /config/.env and saved there on first creation.
cd "${APP_ROOT:-/var/www/html}" || exit 0
[ -f artisan ] || exit 0
if [ -d /config ] && [ -f /config/.env ]; then
echo "Using existing /config/.env"
cp /config/.env .env
elif [ ! -f .env ] && [ -f .env.example ]; then
echo "Creating .env from example"
cp .env.example .env
chown "$(stat -c %u:%g .env.example)" .env
if [ -d /config ]; then
cp .env /config/.env
fi
fi
+14
View File
@@ -0,0 +1,14 @@
#!/bin/sh
# Generates APP_KEY only when none exists yet (env or .env), so an existing key is never rotated.
cd "${APP_ROOT:-/var/www/html}" || exit 0
[ -f artisan ] || exit 0
[ -f .env ] || exit 0
[ -n "$APP_KEY" ] && exit 0
if ! grep -Eq '^APP_KEY=.+' .env; then
echo "Generating application key"
php artisan key:generate --force --no-interaction
[ -d /config ] && cp .env /config/.env
fi
exit 0
+9
View File
@@ -0,0 +1,9 @@
#!/bin/sh
# Clear Laravel caches
[ -f artisan ] || exit 0
echo "Clearing Laravel caches"
php artisan cache:clear
php artisan config:clear
php artisan route:clear
php artisan view:clear
+8
View File
@@ -0,0 +1,8 @@
#!/bin/sh
# SQLite database initialization
if grep -iq "^DB_CONNECTION=sqlite" .env && [ "$DB_CONNECTION" = "sqlite" ]; then
if [ ! -f database/database.sqlite ]; then
echo "Creating empty SQLite database"
touch database/database.sqlite
fi
fi
+6
View File
@@ -0,0 +1,6 @@
#!/bin/sh
# Link storage and seed database if first init
[ -f artisan ] || exit 0
echo "Linking storage directory"
php artisan storage:link
+6
View File
@@ -0,0 +1,6 @@
#!/bin/sh
# Migrate database
[ -f artisan ] || exit 0
echo "Running database migrations"
php artisan migrate --force --no-interaction
@@ -0,0 +1,12 @@
#!/bin/sh
cat > /etc/supervisor/supervisord.conf <<'EOF'
[supervisord]
nodaemon=true
logfile=/var/log/supervisor/supervisord.log
[include]
files = /etc/supervisor/conf.d/*.conf
EOF
# nodaemon=true keeps supervisord in the foreground, so detach it here
supervisord -c /etc/supervisor/supervisord.conf &
@@ -0,0 +1,20 @@
[program:queue-default]
command=/usr/local/bin/php %(ENV_APP_ROOT)s/artisan queue:work --sleep=3 --tries=3 --queue=default,importstatistics
user=www-data
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/queue-default.log
[program:queue-statistics]
command=/usr/local/bin/php %(ENV_APP_ROOT)s/artisan queue:work --sleep=5 --tries=3 --queue=statistics
user=www-data
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/queue-statistics.log
[program:queue-detections]
command=/usr/local/bin/php %(ENV_APP_ROOT)s/artisan queue:work --sleep=3 --tries=3 --queue=detections
user=www-data
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/queue-detections.log
@@ -0,0 +1,6 @@
[program:scheduler]
command=/usr/local/bin/php %(ENV_APP_ROOT)s/artisan schedule:work
user=www-data
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/scheduler.log
@@ -0,0 +1,8 @@
; Example only, not loaded (supervisor includes just *.conf).
; To enable it, copy it to /etc/supervisor/conf.d/reverb.conf (or rename it to reverb.conf in supervisor.d).
[program:reverb]
command=/usr/local/bin/php %(ENV_APP_ROOT)s/artisan reverb:start --host=0.0.0.0 --no-interaction --debug
user=www-data
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/reverb.log