docker-files for scheduler, worker and updates

This commit is contained in:
Alexander Gabriel 2026-06-28 15:28:33 +02:00
parent 79789f41dd
commit 084fb3e182
4 changed files with 85 additions and 0 deletions

7
.dockerignore Normal file
View File

@ -0,0 +1,7 @@
vendor/
node_modules/
public/build/
.git/
.env
storage/framework/
storage/logs/

17
Dockerfile Normal file
View File

@ -0,0 +1,17 @@
FROM php:8.3-cli
RUN apt-get update && apt-get install -y \
git curl zip unzip \
libsqlite3-dev libpng-dev libzip-dev libonig-dev libexif-dev \
gmic \
&& docker-php-ext-install pdo_sqlite gd zip mbstring bcmath pcntl exif \
&& rm -rf /var/lib/apt/lists/*
# Node.js 22
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
&& apt-get install -y nodejs \
&& rm -rf /var/lib/apt/lists/*
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
WORKDIR /app

39
docker-compose.yml Normal file
View File

@ -0,0 +1,39 @@
services:
init:
build: .
command: sh docker/init.sh
env_file: .env
volumes:
- .:/app
app:
build: .
command: php artisan serve --host=0.0.0.0 --port=8000
env_file: .env
ports:
- "8000:8000"
volumes:
- .:/app
depends_on:
init:
condition: service_completed_successfully
scheduler:
build: .
command: php artisan schedule:work
env_file: .env
volumes:
- .:/app
depends_on:
init:
condition: service_completed_successfully
worker:
build: .
command: php artisan queue:work --tries=3
env_file: .env
volumes:
- .:/app
depends_on:
init:
condition: service_completed_successfully

22
docker/init.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/sh
set -e
echo "==> Installing Composer dependencies..."
composer install --no-interaction --prefer-dist --optimize-autoloader
echo "==> Installing npm dependencies..."
npm install
echo "==> Building frontend assets..."
npm run build
# Create SQLite database file if it doesn't exist yet
[ -f database/database.sqlite ] || touch database/database.sqlite
echo "==> Running database migrations..."
php artisan migrate --force
echo "==> Linking storage..."
php artisan storage:link --force 2>/dev/null || true
echo "==> Init complete."