{"id":20033099,"url":"https://github.com/adiachenko/docker-image-php-nginx","last_synced_at":"2025-05-05T05:30:57.128Z","repository":{"id":168634580,"uuid":"418114635","full_name":"adiachenko/docker-image-php-nginx","owner":"adiachenko","description":"Configurable Docker image for PHP-FPM with Nginx for several frameworks. Includes SQLite, Composer, Xdebug, Blackfire, NodeJS, database command-line clients and popular PHP extensions.","archived":false,"fork":false,"pushed_at":"2024-05-29T11:35:39.000Z","size":92,"stargazers_count":2,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-08T17:21:23.931Z","etag":null,"topics":["docker","nginx","php"],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adiachenko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-17T11:53:50.000Z","updated_at":"2024-05-29T11:35:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"b19e9790-0a34-4c32-97ec-3424ab280e40","html_url":"https://github.com/adiachenko/docker-image-php-nginx","commit_stats":null,"previous_names":["adiachenko/docker-image-php-nginx"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adiachenko%2Fdocker-image-php-nginx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adiachenko%2Fdocker-image-php-nginx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adiachenko%2Fdocker-image-php-nginx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adiachenko%2Fdocker-image-php-nginx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adiachenko","download_url":"https://codeload.github.com/adiachenko/docker-image-php-nginx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252445746,"owners_count":21749106,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","nginx","php"],"created_at":"2024-11-13T09:44:31.422Z","updated_at":"2025-05-05T05:30:56.839Z","avatar_url":"https://github.com/adiachenko.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Docker PHP-FPM with Nginx\n\n- [Docker PHP-FPM with Nginx](#docker-php-fpm-with-nginx)\n  - [Introduction](#introduction)\n  - [Supported PHP Versions](#supported-php-versions)\n  - [Usage](#usage)\n    - [Apple Silicon](#apple-silicon)\n    - [Production Usage](#production-usage)\n    - [Cron Schedule](#cron-schedule)\n    - [Laravel Octane](#laravel-octane)\n  - [Configuration](#configuration)\n  - [Creating Images](#creating-images)\n\n## Introduction\n\nThis image is based on official PHP-FPM Docker image.\n\nAdditional software:\n\n- Nginx (with pre-made configs for Laravel, Laravel Octane, Symfony and Wordpress)\n- SQLite\n- Composer\n- Xdebug\n- NodeJS\n- Blackfire\n- Command-line clients for MySQL and PostgreSQL to support [migration squashing](https://laravel.com/docs/8.x/migrations#squashing-migrations)\n- htop\n- GNU nano\n- Open SSH\n\nCompiled in modules (according to `php -m`):\n\n```\nbcmath\nblackfire\nCore\nctype\ncurl\ndate\ndom\nexif\nfileinfo\nfilter\nftp\ngd\ngmp\nhash\niconv\nintl\njson\nlibxml\nmbstring\nmysqlnd\nopenssl\npcntl\npcre\nPDO\npdo_mysql\npdo_pgsql\npdo_sqlite\nPhar\nposix\nreadline\nredis\nReflection\nsession\nSimpleXML\nsockets\nsodium\nSPL\nsqlite3\nstandard\ntokenizer\nxdebug\nxml\nxmlreader\nxmlwriter\nZend OPcache\nzip\nzlib\n```\n\n## Supported PHP Versions\n\n- 8.1 (use `adiachenko/php-nginx:8.1`)\n- 8.2 (use `adiachenko/php-nginx:8.2`)\n- 8.3 (use `adiachenko/php-nginx:8.3`)\n\n## Usage\n\nExample `docker-compose.yml` file for Laravel project:\n\n```yml\nversion: '3.8'\n\nservices:\n  app:\n    image: adiachenko/php-nginx\n    environment:\n      - NGINX_SERVER_TYPE=laravel\n    ports:\n      - 8000:80\n    volumes:\n      - ./:/opt/project:cached\n```\n\nYou can set Nginx config suited for your framework using `NGINX_SERVER_TYPE` env variable (container restart required):\n\n- laravel\n- octane\n- symfony\n- wordpress\n\n### Apple Silicon\n\nThis image doesn't **natively** support Apple Silicon, because MySQL doesn't provide [ARM64 version](https://www.mysql.com/support/supportedplatforms/database.html) for Debian which we need in order to install a command-line client.\n\nHowever, you can add `--platform linux/amd64` to run this image under emulation.\n\n### Production Usage\n\nIf you don't mind the size of the image, it's perfectly suitable for production usage. Just enable opcache and adjust other settings using env variables as described in [configuration section](#configuration).\n\n### SSH\n\nIn some circumstances when using private Composer packages you may need SSH keys for authentication. I still recommend [using tokens](https://getcomposer.org/doc/articles/authentication-for-private-packages.md#authentication-for-privately-hosted-packages-and-repositories) with Docker whenever possible, but if you setup does not allow it, you may provide base64 encoded value of your SSH **private** key (e.g. ~/.ssh/id_rsa) here:\n\n\u003e You can use [online base64 encoder](https://www.base64encode.org) to encode the value. Copy all the text from the `id_rsa` file (including comments and the last empty line).\n\u003e If you still get access denied errors with the key encoded in this manner, ensure that you have an empty line in the end before encoding the value.\n\n```\nCONTAINER_SSH_PRIVATE_KEY_BASE64=\n```\n\n### Cron Schedule\n\nYou don't need cron for scheduled tasks in Docker. There are cleaner alternatives for containers like [Ofelia](https://github.com/mcuadros/ofelia). Another option is to run command like [Laravel Cronless Schedule](https://github.com/spatie/laravel-cronless-schedule) in a separate container.\n\nHere is an example using Ofelia with a Laravel app:\n\n```yml\nversion: '3.8'\n\nservices:\n  app:\n    image: adiachenko/php-nginx\n    environment:\n      - NGINX_SERVER_TYPE=laravel\n    ports:\n      - 8000:80\n    volumes:\n      - ./:/opt/project:cached\n    labels:\n      # See https://github.com/mcuadros/ofelia#docker-labels-configurations\n      ofelia.enabled: 'true'\n      ofelia.job-exec.schedule.schedule: '@every 60s'\n      ofelia.job-exec.schedule.command: 'php artisan schedule:run'\n\n  ofelia:\n    depends_on:\n      - app\n    image: mcuadros/ofelia:v0.3.6\n    command: daemon --docker\n    volumes:\n      - /var/run/docker.sock:/var/run/docker.sock:ro\n```\n\n### Laravel Octane\n\n\u003e This image only supports Roadrunner server.\n\nOctane runs as PHP CLI application so we must adjust `docker-compose.yml` file accordingly:\n\n```yml\nversion: '3.8'\n\nservices:\n  app:\n    image: adiachenko/php-nginx\n    # Run the image without PHP-FPM\n    command: \u003e\n      bash -c \"envsubst \u003c /etc/nginx/conf.d/default.template \u003e /etc/nginx/sites-available/default \u0026\u0026 nginx\"\n    environment:\n      - NGINX_SERVER_TYPE=octane\n      - PHP_OPCACHE_ENABLE_CLI=1\n    ports:\n      - 8000:80\n    volumes:\n      - ./:/opt/project:cached\n```\n\n## Configuration\n\nThis image ships with the default `php.ini` for production environments.\n\nDefault Opcache settings are adjusted with the following values to improve DX:\n\n\u003e Make sure you disable `opcache.validate_timestamps` for deployed version of your image.\n\n```ini\n; If enabled, OPcache will check for updated scripts every opcache.revalidate_freq\n; seconds. When this directive is disabled, you must reset OPcache manually\n; by running 'kill -USR2 1' inside the container\nopcache.validate_timestamps=1\n\n; How often to check script timestamps for updates, in seconds. 0 will result\n; in OPcache checking for updates on every request. This configuration\n; directive is ignored if opcache.validate_timestamps is disabled.\nopcache.revalidate_freq=0\n```\n\nYou can change configuration using the following environment variables:\n\n| Envitonment Variable                | Default                           |\n| ----------------------------------- | --------------------------------- |\n| PHP_DISPLAY_ERRORS                  | Off                               |\n| PHP_DISPLAY_STARTUP_ERRORS          | Off                               |\n| PHP_ERROR_REPORTING                 | E_ALL \u0026 ~E_DEPRECATED \u0026 ~E_STRICT |\n| PHP_MEMORY_LIMIT                    | 128M                              |\n| PHP_POST_MAX_SIZE                   | 8M                                |\n| PHP_UPLOAD_MAX_SIZE                 | 2M                                |\n| PHP_REALPATH_CACHE_SIZE             | 4K                                |\n| PHP_REALPATH_CACHE_TTL              | 120                               |\n| PHP_OPCACHE_ENABLE_CLI              | 0                                 |\n| PHP_OPCACHE_MEMORY_CONSUMPTION      | 128                               |\n| PHP_OPCACHE_JIT_BUFFER_SIZE         | 0                                 |\n| PHP_OPCACHE_INTERNED_STRINGS_BUFFER | 8                                 |\n| PHP_OPCACHE_MAX_ACCELERATED_FILES   | 10000                             |\n| PHP_OPCACHE_MAX_WASTED_PERCENTAGE   | 5                                 |\n| PHP_OPCACHE_VALIDATE_TIMESTAMPS     | 1                                 |\n| PHP_OPCACHE_SAVE_COMMENTS           | 1                                 |\n| PHP_XDEBUG_MODE                     | off                               |\n| PHP_XDEBUG_CLIENT_HOST              | host.docker.internal              |\n\nYou may also tweak process manager settings:\n\n| Envitonment Variable                | Default                           |\n| ----------------------------------- | --------------------------------- |\n| PHP_FPM_MAX_CHILDREN                | 20                                |\n| PHP_FPM_START_SERVERS               | 2                                 |\n| PHP_FPM_MIN_SPARE_SERVERS           | 1                                 |\n| PHP_FPM_MAX_SPARE_SERVERS           | 3                                 |\n| PHP_FPM_MAX_REQUESTS                | 1000                              |\n\n## Creating Images\n\nBuild images:\n\n```sh\ndocker build --platform linux/amd64 --no-cache -t adiachenko/php-nginx:8.3 .\ndocker build --platform linux/amd64 -t adiachenko/php-nginx:latest .\n```\n\nPush images to Docker Hub:\n\n```\ndocker push adiachenko/php-nginx:8.3\ndocker push adiachenko/php-nginx:latest\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadiachenko%2Fdocker-image-php-nginx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadiachenko%2Fdocker-image-php-nginx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadiachenko%2Fdocker-image-php-nginx/lists"}