From cdbf09e5e41c310825819860a4166d939291cd93 Mon Sep 17 00:00:00 2001 From: Ivo Spijkerman Date: Sun, 31 Aug 2025 16:30:27 +0200 Subject: [PATCH] add Docker setup --- .dockerignore | 23 +++++++++ .env.example | 8 +-- .github/workflows/issues.yml | 12 ----- .github/workflows/pull-requests.yml | 12 ----- .github/workflows/tests.yml | 47 ------------------ .github/workflows/update-changelog.yml | 13 ----- Dockerfile | 49 +++++++++++++++++++ docker-compose.yml | 36 ++++++++++++++ docker/etc/nginx/http.d/default.conf | 21 ++++++++ docker/etc/supervisor/conf.d/supervisord.conf | 25 ++++++++++ docker/start.sh | 15 ++++++ 11 files changed, 173 insertions(+), 88 deletions(-) create mode 100644 .dockerignore delete mode 100644 .github/workflows/issues.yml delete mode 100644 .github/workflows/pull-requests.yml delete mode 100644 .github/workflows/tests.yml delete mode 100644 .github/workflows/update-changelog.yml create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 docker/etc/nginx/http.d/default.conf create mode 100644 docker/etc/supervisor/conf.d/supervisord.conf create mode 100755 docker/start.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..a15e5866 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,23 @@ +/node_modules +/public/hot +/public/storage +/storage/*.key +/vendor +.env +.env.backup +.phpunit.result.cache +Homestead.json +Homestead.yaml +npm-debug.log +yarn-error.log +.idea +.vscode +.vagrant +.git +.gitea +.gitignore +.gitattributes +*.log +docker-compose.yml +Dockerfile +.dockerignore diff --git a/.env.example b/.env.example index 35db1ddf..4ca9a36b 100644 --- a/.env.example +++ b/.env.example @@ -1,12 +1,12 @@ -APP_NAME=Laravel +APP_NAME=Ponzi APP_ENV=local APP_KEY= APP_DEBUG=true APP_URL=http://localhost -APP_LOCALE=en -APP_FALLBACK_LOCALE=en -APP_FAKER_LOCALE=en_US +APP_LOCALE=nl +APP_FALLBACK_LOCALE=nl +APP_FAKER_LOCALE=nl_NL APP_MAINTENANCE_DRIVER=file # APP_MAINTENANCE_STORE=database diff --git a/.github/workflows/issues.yml b/.github/workflows/issues.yml deleted file mode 100644 index 230257c2..00000000 --- a/.github/workflows/issues.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: Issues - -on: - issues: - types: [labeled] - -permissions: - issues: write - -jobs: - help-wanted: - uses: laravel/.github/.github/workflows/issues.yml@main diff --git a/.github/workflows/pull-requests.yml b/.github/workflows/pull-requests.yml deleted file mode 100644 index 6f9f97ea..00000000 --- a/.github/workflows/pull-requests.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: Pull Requests - -on: - pull_request_target: - types: [opened] - -permissions: - pull-requests: write - -jobs: - uneditable: - uses: laravel/.github/.github/workflows/pull-requests.yml@main diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index e43d40dd..00000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Tests - -on: - push: - branches: - - master - - '*.x' - pull_request: - schedule: - - cron: '0 0 * * *' - -permissions: - contents: read - -jobs: - tests: - runs-on: ubuntu-latest - - strategy: - fail-fast: true - matrix: - php: [8.2, 8.3, 8.4] - - name: PHP ${{ matrix.php }} - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite - coverage: none - - - name: Install Composer dependencies - run: composer install --prefer-dist --no-interaction --no-progress - - - name: Copy environment file - run: cp .env.example .env - - - name: Generate app key - run: php artisan key:generate - - - name: Execute tests - run: php artisan test diff --git a/.github/workflows/update-changelog.yml b/.github/workflows/update-changelog.yml deleted file mode 100644 index 70352331..00000000 --- a/.github/workflows/update-changelog.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: Update Changelog - -on: - release: - types: [released] - -permissions: {} - -jobs: - update: - permissions: - contents: write - uses: laravel/.github/.github/workflows/update-changelog.yml@main diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..c6c88d0d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,49 @@ +# Multi-stage build for smaller final image +FROM php:8.4-fpm-alpine AS base + +# Install system dependencies +RUN apk add --no-cache \ + nginx \ + supervisor \ + curl \ + zip \ + unzip \ + git \ + oniguruma-dev \ + libpng-dev \ + libjpeg-turbo-dev \ + freetype-dev \ + libzip-dev \ + postgresql-dev \ + mysql-client + +# Install PHP extensions +RUN docker-php-ext-configure gd --with-freetype --with-jpeg \ + && docker-php-ext-install pdo pdo_mysql pdo_pgsql mbstring exif pcntl bcmath gd zip + +# Install Composer +COPY --from=composer:latest /usr/bin/composer /usr/bin/composer + +# Set working directory +WORKDIR /var/www/html + +# Copy config files +COPY docker/etc/nginx/http.d/default.conf /etc/nginx/http.d/default.conf +COPY docker/etc/supervisor/conf.d/supervisord.conf /etc/supervisor/conf.d/supervisord.conf +COPY docker/start.sh ./start.sh +COPY .env.example ./.env + +# Copy application files +COPY . . + +# Install dependencies +RUN composer install --no-dev --optimize-autoloader + +# Set permissions +RUN chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache \ + && chmod -R 775 /var/www/html/storage /var/www/html/bootstrap/cache + + +EXPOSE 80 + +CMD ["./start.sh"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..4547b21b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,36 @@ +services: + server: + build: . + container_name: ponzi-app + ports: + - "1213:80" + environment: + - APP_KEY=base64:i2khvsOjLkIe1IwUOB6KACq4xoT2RnXvv5XQbDsVws4= # For dev only, is not used anywhere else + - DB_CONNECTION=mariadb + - DB_HOST=ponzi-db + - DB_DATABASE=ponzi + - DB_USERNAME=root + - DB_PASSWORD=someroot + depends_on: + - db + restart: unless-stopped + + db: + image: mariadb:10 + container_name: ponzi-db + command: '--default-authentication-plugin=mysql_native_password' + volumes: + - db_data:/var/lib/mysql + restart: unless-stopped + environment: + - MYSQL_ROOT_PASSWORD=someroot + - MYSQL_DATABASE=ponzi + - MYSQL_USER=ponzi + - MYSQL_PASSWORD=ponzipass + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-psomeroot"] + interval: 10s + timeout: 5s + retries: 5 +volumes: + db_data: {} diff --git a/docker/etc/nginx/http.d/default.conf b/docker/etc/nginx/http.d/default.conf new file mode 100644 index 00000000..0aac486c --- /dev/null +++ b/docker/etc/nginx/http.d/default.conf @@ -0,0 +1,21 @@ +server { + listen 80; + server_name localhost; + root /var/www/html/public; + index index.php index.html; + + location / { + try_files $uri $uri/ /index.php?$query_string; + } + + location ~ \.php$ { + fastcgi_pass 127.0.0.1:9000; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; + include fastcgi_params; + } + + location ~ /\.(?!well-known).* { + deny all; + } +} diff --git a/docker/etc/supervisor/conf.d/supervisord.conf b/docker/etc/supervisor/conf.d/supervisord.conf new file mode 100644 index 00000000..1d390bd5 --- /dev/null +++ b/docker/etc/supervisor/conf.d/supervisord.conf @@ -0,0 +1,25 @@ +[supervisord] +nodaemon=true +user=root +logfile=/var/log/supervisor/supervisord.log +pidfile=/var/run/supervisord.pid + +[program:php-fpm] +command=/usr/local/sbin/php-fpm -F +autostart=true +autorestart=true +priority=5 +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 + +[program:nginx] +command=nginx -g "daemon off;" +autostart=true +autorestart=true +priority=10 +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/docker/start.sh b/docker/start.sh new file mode 100755 index 00000000..31f197c3 --- /dev/null +++ b/docker/start.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +set -ex +mkdir -p /var/log/supervisor + +# Run migrations +php artisan migrate --force + +# Clear and cache config +php artisan config:cache +php artisan route:cache +php artisan view:cache + +# Start supervisor +/usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf