diff --git a/.dockerignore b/.dockerignore index c15a495..9372d11 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,10 +2,12 @@ /config/parameters.yml /tests /var +.idea +.git .gitignore .php-cs-fixer.dist.php .phpstorm.meta.php -.travis.yml +.phpunit.cache docker-compose.yml ide-twig.json phpstan.neon.dist diff --git a/.gitignore b/.gitignore index a095e5b..6185216 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ config/parameters.yml /composer.phar /var/* /.composer +.phpunit.cache # Satis default configuration satis.json diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8016201..0000000 --- a/.travis.yml +++ /dev/null @@ -1,28 +0,0 @@ -language: php - -php: - - 7.3 - - 7.4 - - 8.0 - -matrix: - fast_finish: true - -cache: - directories: - - $HOME/.composer - - vendor - -git: - depth: 1 - -before_install: - - phpenv config-rm xdebug.ini - -install: - - 'cp -f config/parameters.yml.dist config/parameters.yml' - - composer install -n --no-progress --prefer-dist - -script: - - bin/phpunit - - bin/phpstan analyse diff --git a/README.md b/README.md index 78f962f..4870877 100644 --- a/README.md +++ b/README.md @@ -77,39 +77,26 @@ You can run satisfy using prebuilt docker image. Here is an example how to setup 2. Add parameters.yml file, can be copied from config/parameters.yml.dist 3. Add auth.json with all required composer authentication tokens 4. Add simple satis.json with basic information -5. Add nginx dir with site configuration templates -6. Create docker-compose.yml using example below -7. Start containers `docker-compose up` -8. Access container shell `docker-compose exec php bash` -9. Run initial build `./bin/satis build` -10. Open satis page on `http://localhost:8000` +5. Create docker-compose.yml using example below +6. Start containers `docker-compose up` +7. Access container shell `docker-compose exec php bash` +8. Run initial build `./bin/satis build` +9. Open satis page on `http://localhost:8000` ``` version: '3' services: php: image: ghcr.io/project-satisfy/satisfy:latest + ports: + - "${APP_PORT:-8000}:80" volumes: - - ./satis.json:/var/www/satisfy/satis.json - - ./parameters.yml:/var/www/satisfy/config/parameters.yml + - ./satis.json:/var/www/html/satis.json + - ./parameters.yml:/var/www/html/config/parameters.yml - ./auth.json:/var/www/.composer/auth.json:ro - - /var/www/satisfy environment: APP_ENV: ${APP_ENV:-dev} APP_DEBUG: ${APP_DEBUG:-1} - - nginx: - image: nginx:1.22-alpine - ports: - - "${APP_PORT:-8000}:80" - volumes: - - ./nginx:/etc/nginx/templates - volumes_from: - - php:ro - environment: - - PHP_SERVICE_NAME=php - depends_on: - - php ``` ## Authors diff --git a/config/config.yml b/config/config.yml index a9c2996..2978ab0 100644 --- a/config/config.yml +++ b/config/config.yml @@ -29,6 +29,7 @@ monolog: type: fingers_crossed action_level: '%log.level%' handler: '%log.handler%' + bubble: false file_log: type: rotating_file path: "%kernel.logs_dir%/%kernel.environment%.log" diff --git a/docker-compose.yml b/docker-compose.yml index 0a51cc2..047b5ef 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,24 +4,15 @@ services: build: context: ./docker/php container_name: satisfy_php - user: www-data - working_dir: /var/www/satisfy + working_dir: /var/www/html + ports: + - "${APP_PORT:-8000}:80" volumes: - - .:/var/www/satisfy + - .:/var/www/html + - ./docker/php/unit.json:/docker-entrypoint.d/config.json - /var/www/.composer environment: APP_ENV: ${APP_ENV:-dev} APP_DEBUG: ${APP_DEBUG:-1} - APP_PATH: /var/www/satisfy - - nginx: - image: nginx:1.22-alpine - ports: - - "${APP_PORT:-8000}:80" - volumes: - - .:/var/www/satisfy - - ./docker/nginx/templates:/etc/nginx/templates - environment: - - PHP_SERVICE_NAME=php - depends_on: - - php + APP_PATH: /var/www/html + COMPOSER_HOME: /var/www/.composer diff --git a/docker/nginx/templates/default.conf.template b/docker/nginx/templates/default.conf.template deleted file mode 100644 index ca9c2c8..0000000 --- a/docker/nginx/templates/default.conf.template +++ /dev/null @@ -1,20 +0,0 @@ -server { - listen 80; - root /var/www/satisfy/public; - server_name _; - index index.html index.php; - location / { - try_files $uri $uri/ /index.php?$query_string; - } - - location ~ ^(.+\.php)(.*) { - try_files $uri /index.php =404; - - fastcgi_split_path_info ^(.+\.php)(.*)$; - fastcgi_pass ${PHP_SERVICE_NAME}:9000; - - fastcgi_param PATH_INFO $fastcgi_path_info; - fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; - include fastcgi_params; - } -} diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile index 23881ea..8b00e25 100644 --- a/docker/php/Dockerfile +++ b/docker/php/Dockerfile @@ -1,10 +1,10 @@ -FROM php:8.1-fpm +FROM unit:1.32.0-php8.2 RUN apt update && \ apt install -qy wget curl git zip unzip && \ apt clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/download/2.1.58/install-php-extensions /usr/local/bin/ +ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/download/2.2.5/install-php-extensions /usr/local/bin/ RUN install-php-extensions @composer zip RUN chown -R www-data:www-data /var/www @@ -14,3 +14,5 @@ COPY php.ini /usr/local/etc/php/conf.d/satisfy.ini USER www-data RUN mkdir -p ~/.ssh && chmod 0700 ~/.ssh && ssh-keyscan -H github.com >> ~/.ssh/known_hosts && \ mkdir -p ~/.composer && chown www-data:www-data ~/.composer + +USER root diff --git a/docker/php/package.Dockerfile b/docker/php/package.Dockerfile index 5989291..86b3d51 100644 --- a/docker/php/package.Dockerfile +++ b/docker/php/package.Dockerfile @@ -1,12 +1,13 @@ -FROM php:8.2-fpm +FROM unit:1.32.0-php8.2 RUN apt update && \ apt install -qy wget curl git zip unzip && \ apt clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/download/2.1.58/install-php-extensions /usr/local/bin/ +ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/download/2.2.5/install-php-extensions /usr/local/bin/ RUN install-php-extensions @composer zip +COPY docker/php/unit.json /docker-entrypoint.d/config.json COPY docker/php/php.ini /usr/local/etc/php/conf.d/satisfy.ini RUN chown -R www-data:www-data /var/www @@ -14,16 +15,19 @@ USER www-data RUN mkdir -p ~/.ssh && chmod 0700 ~/.ssh && ssh-keyscan -H github.com >> ~/.ssh/known_hosts && \ mkdir -p ~/.composer && \ wget -O ~/.composer/keys.dev.pub https://composer.github.io/snapshots.pub && \ - wget -O ~/.composer/keys.tags.pub https://composer.github.io/releases.pub && \ - mkdir -p /var/www/satisfy/var && \ - mkdir -p /var/www/satisfy/public + wget -O ~/.composer/keys.tags.pub https://composer.github.io/releases.pub +VOLUME /var/www/.composer -ENV APP_PATH=/var/www/satisfy +ENV APP_PATH=/var/www/html ENV APP_ENV=prod ENV APP_DEBUG=0 -WORKDIR /var/www/satisfy +ENV COMPOSER_HOME=/var/www/.composer +ENV COMPOSER_CACHE=/var/www/html/var/cache/composer +WORKDIR /var/www/html -VOLUME /var/www/.composer -VOLUME /var/www/satisfy +COPY --chown=www-data:www-data . /var/www/html/ + +RUN mkdir /var/www/html/var +VOLUME /var/www/html/var -COPY --chown=www-data:www-data . /var/www/satisfy/ +USER root diff --git a/docker/php/unit.json b/docker/php/unit.json new file mode 100644 index 0000000..f91de9d --- /dev/null +++ b/docker/php/unit.json @@ -0,0 +1,52 @@ +{ + "listeners": { + "*:80": { + "pass": "routes" + } + }, + "routes": [ + { + "match": { + "uri": [ + "*.php", + "*.php/*" + ] + }, + "action": { + "pass": "applications/satisfy/direct" + } + }, + { + "action": { + "share": "/var/www/html/public$uri", + "fallback": { + "pass": "applications/satisfy/index" + } + } + } + ], + "applications": { + "satisfy": { + "type": "php", + "processes": { + "max": 16, + "spare": 1, + "idle_timeout": 30 + }, + "user": "www-data", + "group": "www-data", + "working_directory": "/var/www/html", + "stderr": "/dev/stderr", + "stdout": "/dev/stdout", + "targets": { + "direct": { + "root": "/var/www/html" + }, + "index": { + "root": "/var/www/html/public", + "script": "index.php" + } + } + } + } +}