diff --git a/.editorconfig b/.editorconfig index 8f0de65c..dd9a2b51 100644 --- a/.editorconfig +++ b/.editorconfig @@ -13,6 +13,3 @@ trim_trailing_whitespace = false [*.{yml,yaml}] indent_size = 2 - -[docker-compose.yml] -indent_size = 4 diff --git a/.env.example b/.env.example index 32b5d026..41325f63 100644 --- a/.env.example +++ b/.env.example @@ -2,7 +2,7 @@ APP_NAME=Laravel APP_ENV=local APP_KEY= APP_DEBUG=true -APP_URL=http://localhost +APP_URL=http://laravel.localhost LOG_CHANNEL=stack LOG_DEPRECATIONS_CHANNEL=null diff --git a/Caddyfile b/Caddyfile new file mode 100644 index 00000000..7fb03163 --- /dev/null +++ b/Caddyfile @@ -0,0 +1,11 @@ +laravel.localhost { + tls internal + root * /home/laravel/laravel.su/public + + php_fastcgi php:9000 { + root /home/laravel/laravel.su/public + } + + file_server + encode gzip +} diff --git a/composer.json b/composer.json index 71375dec..44a7a92a 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ ], "license": "CC BY-NC-SA 4.0", "require": { - "php": ">=8.1", + "php": "^8.3", "cagilo/cagilo": "^3.2", "doctrine/dbal": "^3.7", "esplora/spire": "0.0.1", diff --git a/config/database.php b/config/database.php index b5e3797d..04dab71a 100644 --- a/config/database.php +++ b/config/database.php @@ -15,7 +15,7 @@ | */ - 'default' => env('DB_CONNECTION', 'mysql'), + 'default' => env('DB_CONNECTION', 'sqlite'), /* |-------------------------------------------------------------------------- diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..f00f0733 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,40 @@ +version: "3.8" + +services: + caddy: + image: caddy:2.7-alpine + container_name: laravelsu-caddy + restart: unless-stopped + working_dir: /home/laravel/laravel.su + env_file: + - path: .env + required: false + ports: + - "${LARAVEL_SU_HTTP_PUBLIC_PORT:-80}:80" + - "${LARAVEL_SU_HTTPS_PUBLIC_PORT:-443}:443" + - "${LARAVEL_SU_HTTPS_PUBLIC_PORT:-443}:443/udp" + volumes: + - ./Caddyfile:/etc/caddy/Caddyfile + - .:/home/laravel/laravel.su + depends_on: + - php + networks: + - laravel_su + + php: + build: docker/php + container_name: laravelsu-php + working_dir: /home/laravel/laravel.su + env_file: + - path: .env + required: false + volumes: + - .:/home/laravel/laravel.su + - ./docker/php/php.ini:/usr/local/etc/php/conf.d/local.ini + networks: + - laravel_su + +networks: + laravel_su: + name: laravel_su + driver: bridge diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile new file mode 100644 index 00000000..475e521e --- /dev/null +++ b/docker/php/Dockerfile @@ -0,0 +1,74 @@ +FROM php:8.3-fpm + +WORKDIR "/home/laravel/laravel.su" + +# Fix debconf warnings upon build +ARG DEBIAN_FRONTEND=noninteractive + +# ------------------------------------------------------------------------------ +# Install Dependencies +# ------------------------------------------------------------------------------ + +RUN apt-get update \ + && pecl channel-update pecl.php.net \ + && apt-get -y --no-install-recommends install \ + libsqlite3-dev \ + libzip-dev \ + libicu-dev \ + libpq-dev \ + unzip \ + git \ + curl + +# ------------------------------------------------------------------------------ +# Install PHP +# ------------------------------------------------------------------------------ + +# Composer +RUN curl -sS https://getcomposer.org/installer | \ + php -- --install-dir=/usr/local/bin --filename=composer + +# APCU +RUN pecl install apcu \ + && docker-php-ext-enable apcu + +# INTL +RUN docker-php-ext-install intl \ + && docker-php-ext-enable intl + +# PDO PostgreSQL +RUN docker-php-ext-install pdo_sqlite \ + && docker-php-ext-enable pdo_sqlite + +# Zip +RUN docker-php-ext-install zip \ + && docker-php-ext-enable zip + +# Opcache +RUN docker-php-ext-install opcache + +# Sockets +RUN docker-php-ext-install sockets + +# ------------------------------------------------------------------------------ +# Cleanup Dependencies +# ------------------------------------------------------------------------------ + +RUN apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* \ + && ln -sf /usr/share/zoneinfo/Etc/UTC /etc/localtime + +# ------------------------------------------------------------------------------ +# Copy Runtime Files +# ------------------------------------------------------------------------------ + +COPY --chown=root:root boot.sh /etc/init.d/boot.sh +RUN chmod +x /etc/init.d/boot.sh + +# ------------------------------------------------------------------------------ +# Execute Server +# ------------------------------------------------------------------------------ + +RUN useradd -u 1000 -m laravel +USER laravel + +ENTRYPOINT ["/etc/init.d/boot.sh"] diff --git a/docker/php/boot.sh b/docker/php/boot.sh new file mode 100644 index 00000000..0e5d4db7 --- /dev/null +++ b/docker/php/boot.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +set -e + +echo " > Prepare server APP_ENV=${APP_ENV}" + +echo "$ copy .env.example .env" +cp -n /home/laravel/laravel.su/.env.example /home/laravel/laravel.su/.env + +# NON Production Environment +if [[ ${APP_ENV} != *"production"* ]]; +then + # -------------------------------------------------------------------------- + # Additional installation of DEV dependencies + # -------------------------------------------------------------------------- + echo "$ touch database/database.sqlite" + touch /home/laravel/laravel.su/database/database.sqlite + + echo "$ composer install -n -v" + composer install -n -v + + echo "$ artisan key:generate" + php /home/laravel/laravel.su/artisan key:generate + + echo "$ artisan migrate" + php /home/laravel/laravel.su/artisan migrate +fi + +# ---------------------------------------------------------------------------- +# Warmup +# ---------------------------------------------------------------------------- + +echo "$ artisan cache:clear" +php /home/laravel/laravel.su/artisan cache:clear + +echo "$ artisan config:clear" +php /home/laravel/laravel.su/artisan config:clear + +# ------------------------------------------------------------------------------ +# Execute Server +# ------------------------------------------------------------------------------ + +echo "Ready (APP_ENV=${APP_ENV}, APP_DEBUG=${APP_DEBUG})" + +exec php-fpm diff --git a/docker/php/php.ini b/docker/php/php.ini new file mode 100644 index 00000000..af9cf05a --- /dev/null +++ b/docker/php/php.ini @@ -0,0 +1,25 @@ +[PHP] +; Maximum allowed size for uploaded files. +; https://php.net/upload-max-filesize +upload_max_filesize = 100M + +; Maximum number of files that can be uploaded via a single request +max_file_uploads = 20 + +; Maximum size of POST data that PHP will accept. +; Its value may be 0 to disable the limit. It is ignored if POST data reading +; is disabled through enable_post_data_reading. +; https://php.net/post-max-size +post_max_size = 100M + +[Date] +; Defines the default timezone used by the date functions +; https://php.net/date.timezone +date.timezone = UTC + +[opcache] +; Determines if Zend OPCache is enabled +opcache.enable=1 + +; Determines if Zend OPCache is enabled for the CLI version of PHP +opcache.enable_cli=1