diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..9e3085d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +vendor/ +node_modules/ +public/build/ +.git/ +.env +storage/framework/ +storage/logs/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d0543e7 --- /dev/null +++ b/Dockerfile @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..303527d --- /dev/null +++ b/docker-compose.yml @@ -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 diff --git a/docker/init.sh b/docker/init.sh new file mode 100755 index 0000000..6adb033 --- /dev/null +++ b/docker/init.sh @@ -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."