add Docker setup

This commit is contained in:
Ivo Spijkerman
2025-08-31 16:30:27 +02:00
parent a64f98a3ca
commit cdbf09e5e4
11 changed files with 173 additions and 88 deletions

23
.dockerignore Normal file
View File

@@ -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

View File

@@ -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

View File

@@ -1,12 +0,0 @@
name: Issues
on:
issues:
types: [labeled]
permissions:
issues: write
jobs:
help-wanted:
uses: laravel/.github/.github/workflows/issues.yml@main

View File

@@ -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

View File

@@ -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

View File

@@ -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

49
Dockerfile Normal file
View File

@@ -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"]

36
docker-compose.yml Normal file
View File

@@ -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: {}

View File

@@ -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;
}
}

View File

@@ -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

15
docker/start.sh Executable file
View File

@@ -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