├── .DS_Store ├── .dockerignore ├── .github └── workflows │ ├── build.yml │ ├── manual.yaml │ └── tests.yml ├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── build.sh ├── compose.yaml ├── example ├── default.conf └── docker-compose.yml ├── src ├── docker │ ├── 7.2 │ │ └── Dockerfile │ ├── 7.3 │ │ └── Dockerfile │ ├── 7.4 │ │ └── Dockerfile │ ├── 8.0 │ │ └── Dockerfile │ ├── Dockerfile │ └── Dockerfile.alpine ├── entrypoint.sh ├── index.php ├── opcache.ini ├── php.ini └── supervisor │ └── supervisord.conf ├── tests └── compose.yaml └── version /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jkaninda/laravel-php-fpm/48abada5d79baac208c226ea680b0f45e402ce95/.DS_Store -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | docker-compose.yml 3 | default.conf -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | on: 3 | push: 4 | branches: 5 | - master 6 | jobs: 7 | docker: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - 11 | name: Set up QEMU 12 | uses: docker/setup-qemu-action@v2 13 | - 14 | name: Set up Docker Buildx 15 | uses: docker/setup-buildx-action@v2 16 | - 17 | name: Login to DockerHub 18 | uses: docker/login-action@v2 19 | with: 20 | username: ${{ secrets.DOCKERHUB_USERNAME }} 21 | password: ${{ secrets.DOCKERHUB_TOKEN }} 22 | - 23 | name: Build and push 8.1 24 | uses: docker/build-push-action@v3 25 | with: 26 | file: "./src/docker/Dockerfile" 27 | push: true 28 | platforms: linux/amd64,linux/arm64 29 | build-args: | 30 | phpVersion=8.1 31 | tags: "${{ vars.BUILDKIT_IMAGE }}:8.1" 32 | - 33 | name: Build and push 8.1 alpine 34 | uses: docker/build-push-action@v3 35 | with: 36 | file: "./src/docker/Dockerfile.alpine" 37 | push: true 38 | platforms: linux/amd64,linux/arm64 39 | build-args: | 40 | phpVersion=8.1 41 | tags: "${{ vars.BUILDKIT_IMAGE }}:8.1-alpine" 42 | - 43 | name: Build and push 8.2 44 | uses: docker/build-push-action@v3 45 | with: 46 | file: "./src/docker/Dockerfile" 47 | push: true 48 | platforms: linux/amd64,linux/arm64 49 | build-args: | 50 | phpVersion=8.2 51 | tags: "${{vars.BUILDKIT_IMAGE}}:8.2" 52 | - 53 | name: Build and push 8.2 alpine 54 | uses: docker/build-push-action@v3 55 | with: 56 | file: "./src/docker/Dockerfile.alpine" 57 | push: true 58 | platforms: linux/amd64,linux/arm64 59 | build-args: | 60 | phpVersion=8.2 61 | tags: "${{vars.BUILDKIT_IMAGE}}:8.2-alpine" 62 | - 63 | name: Build and push 8.3 64 | uses: docker/build-push-action@v3 65 | with: 66 | file: "./src/docker/Dockerfile" 67 | push: true 68 | platforms: linux/amd64,linux/arm64 69 | build-args: | 70 | phpVersion=8.3 71 | tags: | 72 | "${{vars.BUILDKIT_IMAGE}}:8.3" 73 | - 74 | name: Build and push 8.3 alpine 75 | uses: docker/build-push-action@v3 76 | with: 77 | file: "./src/docker/Dockerfile.alpine" 78 | push: true 79 | platforms: linux/amd64,linux/arm64 80 | build-args: | 81 | phpVersion=8.3 82 | tags: | 83 | "${{vars.BUILDKIT_IMAGE}}:8.3-alpine" 84 | - 85 | name: Build and push 8.4 alpine 86 | uses: docker/build-push-action@v3 87 | with: 88 | file: "./src/docker/Dockerfile.alpine" 89 | push: true 90 | platforms: linux/amd64,linux/arm64 91 | build-args: | 92 | phpVersion=8.4 93 | tags: | 94 | "${{vars.BUILDKIT_IMAGE}}:8.4-alpine" 95 | - 96 | name: Build and push 8.4 97 | uses: docker/build-push-action@v3 98 | with: 99 | file: "./src/docker/Dockerfile" 100 | push: true 101 | platforms: linux/amd64,linux/arm64 102 | build-args: | 103 | phpVersion=8.4 104 | tags: | 105 | "${{vars.BUILDKIT_IMAGE}}:8.4" 106 | "${{vars.BUILDKIT_IMAGE}}:latest" 107 | 108 | -------------------------------------------------------------------------------- /.github/workflows/manual.yaml: -------------------------------------------------------------------------------- 1 | name: Manual-build 2 | on: 3 | workflow_dispatch: 4 | inputs: 5 | docker_tag: 6 | description: 'Docker tag' 7 | required: true 8 | default: 'latest' 9 | type: string 10 | jobs: 11 | docker: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - 15 | name: Set up QEMU 16 | uses: docker/setup-qemu-action@v3 17 | - 18 | name: Set up Docker Buildx 19 | uses: docker/setup-buildx-action@v3 20 | - 21 | name: Login to DockerHub 22 | uses: docker/login-action@v3 23 | with: 24 | username: ${{ secrets.DOCKERHUB_USERNAME }} 25 | password: ${{ secrets.DOCKERHUB_TOKEN }} 26 | - 27 | name: Build and push 7.2 28 | uses: docker/build-push-action@v3 29 | with: 30 | file: "./src/docker/7.2/Dockerfile" 31 | push: true 32 | tags: "${{vars.BUILDKIT_IMAGE}}:7.2" 33 | - 34 | name: Build and push 7.3 35 | uses: docker/build-push-action@v3 36 | with: 37 | file: "./src/docker/7.3/Dockerfile" 38 | push: true 39 | tags: "${{vars.BUILDKIT_IMAGE}}:7.3" 40 | - 41 | name: Build and push 7.4 42 | uses: docker/build-push-action@v3 43 | with: 44 | file: "./src/docker/7.4/Dockerfile" 45 | push: true 46 | tags: "${{vars.BUILDKIT_IMAGE}}:7.4" 47 | - 48 | name: Build and push 8.0 49 | uses: docker/build-push-action@v3 50 | with: 51 | file: "./src/docker/8.0/Dockerfile" 52 | push: true 53 | tags: "${{vars.BUILDKIT_IMAGE}}:8.0" 54 | - 55 | name: Build and push 8.1 56 | uses: docker/build-push-action@v3 57 | with: 58 | file: "./src/docker/Dockerfile" 59 | push: true 60 | platforms: linux/amd64,linux/arm64 61 | build-args: | 62 | phpVersion=8.1 63 | tags: "${{ vars.BUILDKIT_IMAGE }}:8.1" 64 | - 65 | name: Build and push 8.1 alpine 66 | uses: docker/build-push-action@v3 67 | with: 68 | file: "./src/docker/Dockerfile.alpine" 69 | push: true 70 | platforms: linux/amd64,linux/arm64 71 | build-args: | 72 | phpVersion=8.1 73 | tags: "${{ vars.BUILDKIT_IMAGE }}:8.1-alpine" 74 | - 75 | name: Build and push 8.2 76 | uses: docker/build-push-action@v3 77 | with: 78 | file: "./src/docker/Dockerfile" 79 | push: true 80 | platforms: linux/amd64,linux/arm64 81 | build-args: | 82 | phpVersion=8.2 83 | tags: "${{vars.BUILDKIT_IMAGE}}:8.2" 84 | - 85 | name: Build and push 8.2 alpine 86 | uses: docker/build-push-action@v3 87 | with: 88 | file: "./src/docker/Dockerfile.alpine" 89 | push: true 90 | platforms: linux/amd64,linux/arm64 91 | build-args: | 92 | phpVersion=8.2 93 | tags: "${{vars.BUILDKIT_IMAGE}}:8.2-alpine" 94 | - 95 | name: Build and push 8.3 96 | uses: docker/build-push-action@v3 97 | with: 98 | file: "./src/docker/Dockerfile" 99 | push: true 100 | platforms: linux/amd64,linux/arm64 101 | build-args: | 102 | phpVersion=8.3 103 | tags: | 104 | "${{vars.BUILDKIT_IMAGE}}:8.3" 105 | - 106 | name: Build and push 8.3 alpine 107 | uses: docker/build-push-action@v3 108 | with: 109 | file: "./src/docker/Dockerfile.alpine" 110 | push: true 111 | platforms: linux/amd64,linux/arm64 112 | build-args: | 113 | phpVersion=8.3 114 | tags: | 115 | "${{vars.BUILDKIT_IMAGE}}:8.3-alpine" 116 | - 117 | name: Build and push 8.4 alpine 118 | uses: docker/build-push-action@v3 119 | with: 120 | file: "./src/docker/Dockerfile.alpine" 121 | push: true 122 | platforms: linux/amd64,linux/arm64 123 | build-args: | 124 | phpVersion=8.4 125 | tags: | 126 | "${{vars.BUILDKIT_IMAGE}}:8.4-alpine" 127 | - 128 | name: Build and push 8.4 129 | uses: docker/build-push-action@v3 130 | with: 131 | file: "./src/docker/Dockerfile" 132 | push: true 133 | platforms: linux/amd64,linux/arm64 134 | build-args: | 135 | phpVersion=8.4 136 | tags: | 137 | "${{vars.BUILDKIT_IMAGE}}:8.4" 138 | "${{vars.BUILDKIT_IMAGE}}:latest" -------------------------------------------------------------------------------- /.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | on: 3 | push: 4 | jobs: 5 | integration: 6 | runs-on: ubuntu-latest 7 | steps: 8 | - uses: actions/checkout@v4 9 | - name: Build Docker Image 10 | run: | 11 | docker buildx build -f src/docker/Dockerfile --build-arg phpVersion=8.4 -t ${{ vars.BUILDKIT_IMAGE }}:latest --load . 12 | - name: Verify Docker images 13 | run: | 14 | docker images 15 | - name: Create Laravel project 16 | run: | 17 | composer create-project laravel/laravel laravel 18 | - name: Fix Permission 19 | run: chmod -R 777 ./laravel/storage 20 | - name: Run docker-compose 21 | run: 22 | cp ./tests/compose.yaml compose.yaml && 23 | docker compose -f "compose.yaml" up -d 24 | - name: Create script.js for K6 test 25 | run: | 26 | touch script.js && cat > script.js < /dev/null ; do 47 | echo "Waiting for database connection..." 48 | sleep 5 49 | done 50 | - name: Laravel database migration test 51 | run: | 52 | docker exec php-fpm php artisan migrate 53 | 54 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.history 2 | laravel 3 | docker-compose.yml -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Jonas Kaninda 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | IMAGE_NAME?=jkaninda/laravel-php-fpm 2 | .PHONY: all 3 | all: build 4 | ##@ Build 5 | .PHONY: build 6 | build: build-81 build-82 build-83 build-84 7 | .PHONY: build-80 8 | build-80: 9 | docker build --build-arg phpVersion=8.0 -f src/docker/8.0/Dockerfile -t ${IMAGE_NAME}:8.0 . 10 | .PHONY: build-81 11 | build-81: 12 | docker build --build-arg phpVersion=8.1 -f src/docker/Dockerfile -t ${IMAGE_NAME}:8.1 . 13 | .PHONY: build-82 14 | build-82: 15 | docker build --build-arg phpVersion=8.2 -f src/docker/Dockerfile -t ${IMAGE_NAME}:8.2 . 16 | .PHONY: build-83 17 | build-83: 18 | docker build --build-arg phpVersion=8.3 -f src/docker/Dockerfile -t ${IMAGE_NAME}:8.3 . 19 | .PHONY: build-84 20 | build-84: 21 | docker build --build-arg phpVersion=8.4 -f src/docker/Dockerfile -t ${IMAGE_NAME}:8.4 . 22 | .PHONY: build-81-alpine 23 | build-81-alpine: 24 | docker build --build-arg phpVersion=8.1 -f src/docker/Dockerfile.alpine -t ${IMAGE_NAME}:8.1-alpine . 25 | .PHONY: build-84-alpine 26 | build-84-alpine: 27 | docker build --build-arg phpVersion=8.4 -f src/docker/Dockerfile.alpine -t ${IMAGE_NAME}:8.4-alpine . 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### 🐳 **Docker Image: Laravel PHP-FPM** 2 | 3 | A **ready-to-use container** designed for running PHP-based applications, including Laravel microservices. 4 | This Docker image comes with **PHP-FPM**, offering a robust foundation for your projects with built-in support for essential extensions and configurations. 5 | 6 | [![Build](https://github.com/jkaninda/laravel-php-fpm/actions/workflows/build.yml/badge.svg)](https://github.com/jkaninda/laravel-php-fpm/actions/workflows/build.yml) 7 | [![Tests](https://github.com/jkaninda/laravel-php-fpm/actions/workflows/tests.yml/badge.svg)](https://github.com/jkaninda/laravel-php-fpm/actions/workflows/tests.yml) 8 | ![Docker Image Size (latest by date)](https://img.shields.io/docker/image-size/jkaninda/laravel-php-fpm?style=flat-square) 9 | ![Docker Pulls](https://img.shields.io/docker/pulls/jkaninda/laravel-php-fpm?style=flat-square) 10 | 11 |

12 | 13 | Logo 14 | 15 |

16 | 17 | #### **Features** 18 | - **PHP Application Support**: Optimized to run Laravel or any PHP-based applications. 19 | - **Integrated Extensions**: 20 | - **Database**: MySQL and PostgreSQL. 21 | - **Caching**: Redis and Memcached. 22 | - **Messaging**: Kafka for event-driven architecture. 23 | - **Task Scheduling**: Laravel Scheduler and Cron jobs support. 24 | - **Custom Configuration**: Pre-configured with sensible defaults, allowing seamless customization. 25 | - **Event Handling**: Support for advanced event-driven processes. 26 | - **Optimized for Microservices**: Built with modern PHP microservices in mind. 27 | 28 | This image is ideal for developers looking for a streamlined, high-performance solution to deploy PHP applications with essential tools already integrated. 29 | 30 | 31 | ## Links: 32 | - [Docker Hub](https://hub.docker.com/r/jkaninda/laravel-php-fpm) 33 | - [Github](https://github.com/jkaninda/laravel-php-fpm) 34 | --- 35 | 36 | ## **Supported PHP Versions** 37 | - 8.4 38 | - 8.3 39 | - 8.2 40 | - 8.1 41 | - 8.0 42 | - 7.4 43 | - 7.2 44 | 45 | --- 46 | 47 | ## **Specifications** 48 | 49 | ### **PHP Extensions** 50 | - Composer 51 | - OpenSSL 52 | - XML 53 | - PDO (MySQL and PostgreSQL) 54 | - Rdkafka 55 | - Redis 56 | - Mbstring 57 | - PCNTL 58 | - ZIP 59 | - GD 60 | - BCMath 61 | - Memcached 62 | - Opcache 63 | 64 | ### **Additional Features** 65 | - Laravel Cron Jobs 66 | - Laravel Scheduler 67 | - Supervisord 68 | - Node.js and NPM 69 | 70 | --- 71 | 72 | ## **Getting Started** 73 | 74 | ### **Simple Docker-Compose Example** 75 | ```yaml 76 | services: 77 | php-fpm: 78 | image: jkaninda/laravel-php-fpm:latest 79 | container_name: php-fpm 80 | restart: unless-stopped 81 | user: www-data # For production 82 | volumes: 83 | - ./:/var/www/html 84 | networks: 85 | - default 86 | nginx-server: 87 | image: jkaninda/nginx-fpm:alpine 88 | container_name: nginx-server 89 | restart: unless-stopped 90 | ports: 91 | - 80:80 92 | volumes: 93 | - ./:/var/www/html 94 | environment: 95 | - DOCUMENT_ROOT=/var/www/html/public 96 | - CLIENT_MAX_BODY_SIZE=20M 97 | - PHP_FPM_HOST=php-fpm:9000 98 | networks: 99 | - default 100 | ``` 101 | 102 | ### **Basic Commands** 103 | - **Start Containers** 104 | ```sh 105 | docker compose up -d 106 | ``` 107 | 108 | - **Create a Laravel Project** 109 | ```sh 110 | docker compose exec php-fpm composer create-project --prefer-dist laravel/laravel . 111 | ``` 112 | 113 | - **Generate Application Key** 114 | ```sh 115 | docker compose exec php-fpm php artisan key:generate 116 | ``` 117 | 118 | - **Create Storage Symlink** 119 | ```sh 120 | docker compose exec php-fpm php artisan storage:link 121 | ``` 122 | 123 | - **Fix Permissions** 124 | ```sh 125 | docker compose exec php-fpm chmod -R 777 storage bootstrap/cache 126 | ``` 127 | 128 | - **Run Laravel Migrations** 129 | ```sh 130 | docker compose exec php-fpm php artisan migrate 131 | ``` 132 | 133 | - **Access the Container Shell** 134 | ```sh 135 | docker exec -it php-fpm bash 136 | ``` 137 | 138 | --- 139 | 140 | ## **Advanced Usage with Nginx** 141 | 142 | ### **Docker-Compose with Nginx** 143 | Example of using a custom nginx config: 144 | 145 | ```yaml 146 | version: '3' 147 | services: 148 | php-fpm: 149 | image: jkaninda/laravel-php-fpm 150 | container_name: php-fpm 151 | restart: unless-stopped 152 | volumes: 153 | - ./:/var/www/html 154 | networks: 155 | - default 156 | 157 | nginx-server: 158 | image: nginx:alpine 159 | container_name: nginx-server 160 | restart: unless-stopped 161 | ports: 162 | - 80:80 163 | volumes: 164 | - ./:/var/www/html 165 | - ./default.conf:/etc/nginx/conf.d/default.conf 166 | environment: 167 | - DOCUMENT_ROOT=/var/www/html/public 168 | - CLIENT_MAX_BODY_SIZE=20M 169 | - PHP_FPM_HOST=php-fpm:9000 170 | networks: 171 | - default 172 | ``` 173 | 174 | ### **Nginx Configuration (default.conf)** 175 | 176 | ```conf 177 | server { 178 | listen 80; 179 | index index.php index.html; 180 | root /var/www/html/public; 181 | 182 | location ~ \.php$ { 183 | try_files $uri =404; 184 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 185 | fastcgi_pass php-fpm:9000; 186 | fastcgi_index index.php; 187 | include fastcgi_params; 188 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 189 | fastcgi_param PATH_INFO $fastcgi_path_info; 190 | } 191 | 192 | location / { 193 | try_files $uri $uri/ /index.php?$query_string; 194 | gzip_static on; 195 | } 196 | 197 | client_max_body_size 15M; 198 | server_tokens off; 199 | fastcgi_hide_header X-Powered-By; 200 | } 201 | ``` 202 | 203 | --- 204 | 205 | ## **Custom Build** 206 | 207 | ### **Dockerfile Example** 208 | ```Dockerfile 209 | FROM jkaninda/laravel-php-fpm:8.3 210 | # Copy Laravel project files 211 | COPY . /var/www/html 212 | VOLUME /var/www/html/storage 213 | WORKDIR /var/www/html 214 | 215 | # Fix permissions 216 | RUN chown -R www-data:www-data /var/www/html 217 | 218 | USER www-data 219 | ``` 220 | 221 | --- 222 | 223 | ## **Supervisord Integration** 224 | 225 | ### **Adding Custom Supervisor Processes** 226 | Place configurations in `/etc/supervisor/conf.d/`. 227 | Example Kafka consumer process: 228 | ```conf 229 | [program:kafkaconsume-worker] 230 | process_name=%(program_name)s_%(process_num)02d 231 | command=php /var/www/html/artisan kafka:consumer 232 | autostart=true 233 | autorestart=true 234 | numprocs=1 235 | user=www-data 236 | redirect_stderr=true 237 | stdout_logfile=/var/www/html/storage/logs/kafka.log 238 | ``` 239 | 240 | --- 241 | 242 | ## **Custom PHP Configurations** 243 | Place your custom `php.ini` file at: 244 | ``` 245 | /usr/local/etc/php/conf.d/ 246 | ``` 247 | 248 | --- 249 | 250 | ## **Storage Permissions Fix** 251 | If you encounter permission issues, run: 252 | 253 | ```sh 254 | docker compose exec php-fpm /bin/bash 255 | chown -R www-data:www-data /var/www/html 256 | chmod -R 775 /var/www/html/storage 257 | ``` 258 | 259 | --- 260 | 261 | ### ⭐️ **Support the Project** 262 | If you find this project useful, please give it a ⭐️ on GitHub! 😊 -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ $# -eq 0 ] 3 | then 4 | tag='latest' 5 | else 6 | tag=$1 7 | fi 8 | if [ $tag != 'latest' ] 9 | then 10 | echo 'Build from from tag' 11 | docker build -f src/docker/${tag}/Dockerfile -t jkaninda/laravel-php-fpm:$tag . 12 | else 13 | echo 'Build latest' 14 | docker build -f src/docker/8.3/Dockerfile -t jkaninda/laravel-php-fpm:$tag . 15 | 16 | fi 17 | 18 | -------------------------------------------------------------------------------- /compose.yaml: -------------------------------------------------------------------------------- 1 | services: 2 | php-fpm: 3 | image: jkaninda/laravel-php-fpm 4 | container_name: php-fpm 5 | restart: unless-stopped 6 | user: www-data #Use www-data user production usage 7 | volumes: 8 | #Project root 9 | - ./:/var/www/html 10 | networks: 11 | - web #if you're using networks between containers 12 | #Nginx server 13 | nginx-server: 14 | image: jkaninda/nginx-fpm:alpine 15 | container_name: nginx-server 16 | restart: unless-stopped 17 | ports: 18 | - 80:80 19 | volumes: 20 | - ./:/var/www/html 21 | environment: 22 | - DOCUMENT_ROOT=/var/www/html/public 23 | - CLIENT_MAX_BODY_SIZE=20M 24 | - PHP_FPM_HOST=php-fpm:9000 25 | networks: 26 | - web 27 | networks: 28 | web: 29 | external: false 30 | -------------------------------------------------------------------------------- /example/default.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | index index.php index.html; 4 | error_log /var/log/nginx/error.log; 5 | access_log /var/log/nginx/access.log; 6 | ##Root directory 7 | root /var/www/html/public; 8 | location ~ \.php$ { 9 | try_files $uri =404; 10 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 11 | ## PHP FPM ( php-fpm:9000 ) or [servicename:9000] 12 | fastcgi_pass php-fpm:9000; 13 | fastcgi_index index.php; 14 | include fastcgi_params; 15 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 16 | fastcgi_param PATH_INFO $fastcgi_path_info; 17 | 18 | } 19 | client_max_body_size 15M; 20 | server_tokens off; 21 | 22 | # Hide PHP headers 23 | fastcgi_hide_header X-Powered-By; 24 | fastcgi_hide_header X-CF-Powered-By; 25 | fastcgi_hide_header X-Runtime; 26 | 27 | location / { 28 | try_files $uri $uri/ /index.php?$query_string; 29 | gzip_static on; 30 | } 31 | } -------------------------------------------------------------------------------- /example/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | php-fpm: 4 | image: jkaninda/laravel-php-fpm 5 | container_name: php-fpm 6 | restart: unless-stopped 7 | user: www-data #Use www-data user for production usage 8 | volumes: 9 | #Project root 10 | - ./:/var/www/html 11 | networks: 12 | - default #if you're using networks between containers 13 | #Nginx server 14 | nginx-server: 15 | image: jkaninda/nginx-fpm:alpine 16 | container_name: nginx-server 17 | restart: unless-stopped 18 | ports: 19 | - 80:80 20 | volumes: 21 | #Project root 22 | - ./:/var/www/html 23 | environment: 24 | - DOCUMENT_ROOT=/var/www/html/public 25 | - CLIENT_MAX_BODY_SIZE=20M 26 | - PHP_FPM_HOST=php-fpm:9000 27 | networks: 28 | - default 29 | -------------------------------------------------------------------------------- /src/docker/7.2/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.2-fpm 2 | ARG WORKDIR=/var/www/html 3 | ENV DOCUMENT_ROOT=${WORKDIR} 4 | ENV LARAVEL_PROCS_NUMBER=1 5 | ENV NODE_VERSION=16.x 6 | ARG GROUP_ID=1000 7 | ARG USER_ID=1000 8 | ENV USER_NAME=www-data 9 | ARG GROUP_NAME=www-data 10 | # Install system dependencies 11 | RUN apt-get update && apt-get install -y \ 12 | git \ 13 | curl \ 14 | libfreetype6-dev \ 15 | libjpeg62-turbo-dev \ 16 | libmemcached-dev \ 17 | libzip-dev \ 18 | libpng-dev \ 19 | libonig-dev \ 20 | libxml2-dev \ 21 | librdkafka-dev \ 22 | libpq-dev \ 23 | openssh-server \ 24 | zip \ 25 | unzip \ 26 | supervisor \ 27 | sqlite3 \ 28 | nano \ 29 | cron 30 | 31 | RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION} | bash - 32 | # Install Node 33 | RUN apt-get install -y nodejs 34 | # Clear cache 35 | RUN apt-get clean && rm -rf /var/lib/apt/lists/* 36 | # Install Kafka 37 | RUN git clone https://github.com/arnaud-lb/php-rdkafka.git\ 38 | && cd php-rdkafka \ 39 | && phpize \ 40 | && ./configure \ 41 | && make all -j 5 \ 42 | && make install 43 | 44 | # Install Rdkafka and enable it 45 | RUN docker-php-ext-enable rdkafka \ 46 | && cd .. \ 47 | && rm -rf /php-rdkafka 48 | 49 | # Install PHP extensions zip, mbstring, exif, bcmath, intl 50 | RUN docker-php-ext-configure gd 51 | RUN docker-php-ext-install zip mbstring exif pcntl bcmath -j$(nproc) gd intl 52 | 53 | # Install Redis and enable it 54 | RUN pecl install redis && docker-php-ext-enable redis 55 | 56 | 57 | 58 | # Install the php memcached extension 59 | RUN pecl install memcached && docker-php-ext-enable memcached 60 | 61 | # Install the PHP pdo_mysql extention 62 | RUN docker-php-ext-install pdo_mysql 63 | 64 | # Install the PHP pdo_pgsql extention 65 | RUN docker-php-ext-install pdo_pgsql 66 | 67 | # Install PHP Opcache extention 68 | RUN docker-php-ext-install opcache 69 | 70 | # Install Composer 71 | RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer 72 | 73 | # Set working directory 74 | WORKDIR $WORKDIR 75 | 76 | RUN rm -Rf /var/www/* && \ 77 | mkdir -p /var/www/html 78 | 79 | ADD src/index.php $WORKDIR/index.php 80 | ADD src/php.ini $PHP_INI_DIR/conf.d/ 81 | ADD src/opcache.ini $PHP_INI_DIR/conf.d/ 82 | ADD src/supervisor/supervisord.conf /etc/supervisor/supervisord.conf 83 | 84 | COPY src/entrypoint.sh /usr/local/bin/ 85 | RUN chmod +x /usr/local/bin/entrypoint.sh 86 | RUN ln -s /usr/local/bin/entrypoint.sh / 87 | 88 | ENTRYPOINT ["entrypoint.sh"] 89 | 90 | RUN usermod -u ${USER_ID} ${USER_NAME} 91 | RUN groupmod -g ${USER_ID} ${GROUP_NAME} 92 | RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \ 93 | chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \ 94 | chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \ 95 | chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/ && \ 96 | chown -R ${USER_NAME}:${GROUP_NAME} /tmp 97 | 98 | EXPOSE 9000 99 | CMD [ "entrypoint" ] 100 | -------------------------------------------------------------------------------- /src/docker/7.3/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.3-fpm 2 | ARG WORKDIR=/var/www/html 3 | ENV DOCUMENT_ROOT=${WORKDIR} 4 | ENV LARAVEL_PROCS_NUMBER=1 5 | ENV NODE_VERSION=16.x 6 | ARG GROUP_ID=1000 7 | ARG USER_ID=1000 8 | ENV USER_NAME=www-data 9 | ARG GROUP_NAME=www-data 10 | # Install system dependencies 11 | RUN apt-get update && apt-get install -y \ 12 | git \ 13 | curl \ 14 | libfreetype6-dev \ 15 | libjpeg62-turbo-dev \ 16 | libmemcached-dev \ 17 | libzip-dev \ 18 | libpng-dev \ 19 | libonig-dev \ 20 | libxml2-dev \ 21 | librdkafka-dev \ 22 | libpq-dev \ 23 | openssh-server \ 24 | zip \ 25 | unzip \ 26 | supervisor \ 27 | sqlite3 \ 28 | nano \ 29 | cron 30 | RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION} | bash - 31 | # Install Node 32 | RUN apt-get install -y nodejs 33 | # Clear cache 34 | RUN apt-get clean && rm -rf /var/lib/apt/lists/* 35 | # Install Kafka 36 | RUN git clone https://github.com/arnaud-lb/php-rdkafka.git\ 37 | && cd php-rdkafka \ 38 | && phpize \ 39 | && ./configure \ 40 | && make all -j 5 \ 41 | && make install 42 | 43 | # Install Rdkafka and enable it 44 | RUN docker-php-ext-enable rdkafka \ 45 | && cd .. \ 46 | && rm -rf /php-rdkafka 47 | 48 | # Install PHP extensions zip, mbstring, exif, bcmath, intl 49 | RUN docker-php-ext-configure gd 50 | RUN docker-php-ext-install zip mbstring exif pcntl bcmath -j$(nproc) gd intl 51 | 52 | # Install Redis and enable it 53 | RUN pecl install redis && docker-php-ext-enable redis 54 | 55 | 56 | 57 | # Install the php memcached extension 58 | RUN pecl install memcached && docker-php-ext-enable memcached 59 | 60 | # Install the PHP pdo_mysql extention 61 | RUN docker-php-ext-install pdo_mysql 62 | 63 | # Install the PHP pdo_pgsql extention 64 | RUN docker-php-ext-install pdo_pgsql 65 | 66 | # Install PHP Opcache extention 67 | RUN docker-php-ext-install opcache 68 | 69 | # Install Composer 70 | RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer 71 | 72 | # Set working directory 73 | WORKDIR $WORKDIR 74 | 75 | RUN rm -Rf /var/www/* && \ 76 | mkdir -p /var/www/html 77 | 78 | ADD src/index.php $WORKDIR/index.php 79 | ADD src/php.ini $PHP_INI_DIR/conf.d/ 80 | ADD src/opcache.ini $PHP_INI_DIR/conf.d/ 81 | 82 | ADD src/supervisor/supervisord.conf /etc/supervisor/supervisord.conf 83 | 84 | COPY src/entrypoint.sh /usr/local/bin/ 85 | RUN chmod +x /usr/local/bin/entrypoint.sh 86 | RUN ln -s /usr/local/bin/entrypoint.sh / 87 | 88 | ENTRYPOINT ["entrypoint.sh"] 89 | 90 | RUN usermod -u ${USER_ID} ${USER_NAME} 91 | RUN groupmod -g ${USER_ID} ${GROUP_NAME} 92 | RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \ 93 | chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \ 94 | chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \ 95 | chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/ && \ 96 | chown -R ${USER_NAME}:${GROUP_NAME} /tmp 97 | 98 | EXPOSE 9000 99 | CMD [ "entrypoint" ] 100 | -------------------------------------------------------------------------------- /src/docker/7.4/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.4-fpm 2 | ARG WORKDIR=/var/www/html 3 | ENV DOCUMENT_ROOT=${WORKDIR} 4 | ENV LARAVEL_PROCS_NUMBER=1 5 | ENV NODE_VERSION=16.x 6 | ARG GROUP_ID=1000 7 | ARG USER_ID=1000 8 | ENV USER_NAME=www-data 9 | ARG GROUP_NAME=www-data 10 | # Install system dependencies 11 | RUN apt-get update && apt-get install -y \ 12 | git \ 13 | curl \ 14 | libfreetype6-dev \ 15 | libjpeg62-turbo-dev \ 16 | libmemcached-dev \ 17 | libzip-dev \ 18 | libpng-dev \ 19 | libonig-dev \ 20 | libxml2-dev \ 21 | librdkafka-dev \ 22 | libpq-dev \ 23 | openssh-server \ 24 | zip \ 25 | unzip \ 26 | supervisor \ 27 | sqlite3 \ 28 | nano \ 29 | cron 30 | 31 | RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION} | bash - 32 | # Install Node 33 | RUN apt-get install -y nodejs 34 | # Clear cache 35 | RUN apt-get clean && rm -rf /var/lib/apt/lists/* 36 | # Install Kafka 37 | RUN git clone https://github.com/arnaud-lb/php-rdkafka.git\ 38 | && cd php-rdkafka \ 39 | && phpize \ 40 | && ./configure \ 41 | && make all -j 5 \ 42 | && make install 43 | 44 | # Install Rdkafka and enable it 45 | RUN docker-php-ext-enable rdkafka \ 46 | && cd .. \ 47 | && rm -rf /php-rdkafka 48 | 49 | # Install PHP extensions zip, mbstring, exif, bcmath, intl 50 | RUN docker-php-ext-configure gd 51 | RUN docker-php-ext-install zip mbstring exif pcntl bcmath -j$(nproc) gd intl 52 | 53 | # Install Redis and enable it 54 | RUN pecl install redis && docker-php-ext-enable redis 55 | 56 | 57 | 58 | # Install the php memcached extension 59 | RUN pecl install memcached && docker-php-ext-enable memcached 60 | 61 | # Install the PHP pdo_mysql extention 62 | RUN docker-php-ext-install pdo_mysql 63 | 64 | # Install the PHP pdo_pgsql extention 65 | RUN docker-php-ext-install pdo_pgsql 66 | 67 | # Install PHP Opcache extention 68 | RUN docker-php-ext-install opcache 69 | 70 | # Install Composer 71 | RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer 72 | 73 | # Set working directory 74 | WORKDIR $WORKDIR 75 | 76 | RUN rm -Rf /var/www/* && \ 77 | mkdir -p /var/www/html 78 | 79 | ADD src/index.php $WORKDIR/index.php 80 | ADD src/php.ini $PHP_INI_DIR/conf.d/ 81 | ADD src/opcache.ini $PHP_INI_DIR/conf.d/ 82 | 83 | ADD src/supervisor/supervisord.conf /etc/supervisor/supervisord.conf 84 | 85 | COPY src/entrypoint.sh /usr/local/bin/ 86 | RUN chmod +x /usr/local/bin/entrypoint.sh 87 | RUN ln -s /usr/local/bin/entrypoint.sh / 88 | 89 | ENTRYPOINT ["entrypoint.sh"] 90 | 91 | RUN usermod -u ${USER_ID} ${USER_NAME} 92 | RUN groupmod -g ${USER_ID} ${GROUP_NAME} 93 | RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \ 94 | chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \ 95 | chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \ 96 | chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/ && \ 97 | chown -R ${USER_NAME}:${GROUP_NAME} /tmp 98 | 99 | EXPOSE 9000 100 | CMD [ "entrypoint" ] 101 | -------------------------------------------------------------------------------- /src/docker/8.0/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:8.0-fpm 2 | ARG WORKDIR=/var/www/html 3 | ENV DOCUMENT_ROOT=${WORKDIR} 4 | ENV LARAVEL_PROCS_NUMBER=1 5 | ENV NODE_VERSION=16.x 6 | ARG GROUP_ID=1000 7 | ARG USER_ID=1000 8 | ENV USER_NAME=www-data 9 | ARG GROUP_NAME=www-data 10 | # Install system dependencies 11 | RUN apt-get update && apt-get install -y \ 12 | git \ 13 | curl \ 14 | libfreetype6-dev \ 15 | libjpeg62-turbo-dev \ 16 | libmemcached-dev \ 17 | libzip-dev \ 18 | libpng-dev \ 19 | libonig-dev \ 20 | libxml2-dev \ 21 | librdkafka-dev \ 22 | libpq-dev \ 23 | openssh-server \ 24 | zip \ 25 | unzip \ 26 | supervisor \ 27 | sqlite3 \ 28 | nano \ 29 | cron 30 | RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION} | bash - 31 | # Install Node 32 | RUN apt-get install -y nodejs 33 | 34 | # Clear cache 35 | RUN apt-get clean && rm -rf /var/lib/apt/lists/* 36 | # Install Kafka 37 | RUN git clone https://github.com/arnaud-lb/php-rdkafka.git\ 38 | && cd php-rdkafka \ 39 | && phpize \ 40 | && ./configure \ 41 | && make all -j 5 \ 42 | && make install 43 | 44 | # Install Rdkafka and enable it 45 | RUN docker-php-ext-enable rdkafka \ 46 | && cd .. \ 47 | && rm -rf /php-rdkafka 48 | 49 | # Install PHP extensions zip, mbstring, exif, bcmath, intl 50 | RUN docker-php-ext-configure gd --with-freetype --with-jpeg 51 | RUN docker-php-ext-install zip mbstring exif pcntl bcmath -j$(nproc) gd intl 52 | 53 | # Install Redis and enable it 54 | RUN pecl install redis && docker-php-ext-enable redis 55 | 56 | 57 | 58 | # Install the php memcached extension 59 | RUN pecl install memcached && docker-php-ext-enable memcached 60 | 61 | # Install the PHP pdo_mysql extention 62 | RUN docker-php-ext-install pdo_mysql 63 | 64 | # Install the PHP pdo_pgsql extention 65 | RUN docker-php-ext-install pdo_pgsql 66 | 67 | # Install PHP Opcache extention 68 | RUN docker-php-ext-install opcache 69 | 70 | # Install Composer 71 | RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer 72 | 73 | # Set working directory 74 | WORKDIR $WORKDIR 75 | 76 | RUN rm -Rf /var/www/* && \ 77 | mkdir -p /var/www/html 78 | 79 | ADD src/index.php $WORKDIR/index.php 80 | ADD src/php.ini $PHP_INI_DIR/conf.d/ 81 | ADD src/opcache.ini $PHP_INI_DIR/conf.d/ 82 | 83 | ADD src/supervisor/supervisord.conf /etc/supervisor/supervisord.conf 84 | 85 | COPY src/entrypoint.sh /usr/local/bin/ 86 | RUN chmod +x /usr/local/bin/entrypoint.sh 87 | RUN ln -s /usr/local/bin/entrypoint.sh / 88 | 89 | ENTRYPOINT ["entrypoint.sh"] 90 | 91 | RUN usermod -u ${USER_ID} ${USER_NAME} 92 | RUN groupmod -g ${USER_ID} ${GROUP_NAME} 93 | RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \ 94 | chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \ 95 | chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \ 96 | chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/ && \ 97 | chown -R ${USER_NAME}:${GROUP_NAME} /tmp 98 | 99 | EXPOSE 9000 100 | CMD [ "entrypoint" ] 101 | -------------------------------------------------------------------------------- /src/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG phpVersion=8.3-dev 2 | FROM php:${phpVersion}-fpm 3 | ARG WORKDIR=/var/www/html 4 | ENV DOCUMENT_ROOT=${WORKDIR} 5 | ENV LARAVEL_PROCS_NUMBER=1 6 | ENV NODE_MAJOR=20 7 | ARG GROUP_ID=1000 8 | ARG USER_ID=1000 9 | ENV USER_NAME=www-data 10 | ARG GROUP_NAME=www-data 11 | # Install system dependencies 12 | RUN apt-get update && apt-get install -y \ 13 | git \ 14 | curl \ 15 | libfreetype6-dev \ 16 | libjpeg62-turbo-dev \ 17 | libmemcached-dev \ 18 | libzip-dev \ 19 | libpng-dev \ 20 | libonig-dev \ 21 | libxml2-dev \ 22 | librdkafka-dev \ 23 | libpq-dev \ 24 | openssh-server \ 25 | zip \ 26 | unzip \ 27 | supervisor \ 28 | sqlite3 \ 29 | nano \ 30 | cron 31 | # Install Nodejs 32 | RUN apt-get update && apt-get install -y ca-certificates curl gnupg 33 | RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg 34 | RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list 35 | RUN apt-get update && apt-get install nodejs -y 36 | 37 | # Clear cache 38 | RUN apt-get clean && rm -rf /var/lib/apt/lists/* 39 | # Install Kafka 40 | RUN git clone https://github.com/arnaud-lb/php-rdkafka.git\ 41 | && cd php-rdkafka \ 42 | && phpize \ 43 | && ./configure \ 44 | && make all -j 5 \ 45 | && make install 46 | 47 | # Install Rdkafka and enable it 48 | RUN docker-php-ext-enable rdkafka \ 49 | && cd .. \ 50 | && rm -rf /php-rdkafka 51 | 52 | # Install PHP extensions zip, mbstring, exif, bcmath, intl 53 | RUN docker-php-ext-configure gd --with-freetype --with-jpeg 54 | RUN docker-php-ext-install zip mbstring exif pcntl bcmath -j$(nproc) gd intl 55 | 56 | # Install Redis and enable it 57 | RUN pecl install redis && docker-php-ext-enable redis 58 | 59 | 60 | 61 | # Install the php memcached extension 62 | RUN pecl install memcached && docker-php-ext-enable memcached 63 | 64 | # Install the PHP pdo_mysql extention 65 | RUN docker-php-ext-install pdo_mysql 66 | 67 | # Install the PHP pdo_pgsql extention 68 | RUN docker-php-ext-install pdo_pgsql 69 | 70 | # Install PHP Opcache extention 71 | RUN docker-php-ext-install opcache 72 | 73 | 74 | # Install Composer 75 | RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer 76 | 77 | # Set working directory 78 | WORKDIR $WORKDIR 79 | 80 | RUN rm -Rf /var/www/* && \ 81 | mkdir -p /var/www/html 82 | 83 | ADD src/index.php $WORKDIR/index.php 84 | ADD src/php.ini $PHP_INI_DIR/conf.d/ 85 | ADD src/opcache.ini $PHP_INI_DIR/conf.d/ 86 | ADD src/supervisor/supervisord.conf /etc/supervisor/supervisord.conf 87 | 88 | COPY src/entrypoint.sh /usr/local/bin/ 89 | RUN chmod +x /usr/local/bin/entrypoint.sh 90 | RUN ln -s /usr/local/bin/entrypoint.sh / 91 | 92 | 93 | ENTRYPOINT ["entrypoint.sh"] 94 | 95 | RUN usermod -u ${USER_ID} ${USER_NAME} && \ 96 | groupmod -g ${USER_ID} ${GROUP_NAME} && \ 97 | chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \ 98 | chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \ 99 | chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \ 100 | chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/ && \ 101 | chown -R ${USER_NAME}:${GROUP_NAME} /tmp 102 | 103 | EXPOSE 9000 104 | CMD [ "entrypoint" ] 105 | -------------------------------------------------------------------------------- /src/docker/Dockerfile.alpine: -------------------------------------------------------------------------------- 1 | ARG phpVersion=8.3-dev 2 | FROM php:${phpVersion}-fpm-alpine 3 | ARG WORKDIR=/var/www/html 4 | ENV DOCUMENT_ROOT=${WORKDIR} 5 | ENV LARAVEL_PROCS_NUMBER=1 6 | ARG GROUP_ID=1000 7 | ARG USER_ID=1000 8 | ENV USER_NAME=www-data 9 | ARG GROUP_NAME=www-data 10 | 11 | # Install the PHP pdo_mysql extention 12 | RUN docker-php-ext-install pdo_mysql 13 | 14 | # Install Composer 15 | RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer 16 | 17 | # Set working directory 18 | WORKDIR $WORKDIR 19 | 20 | RUN rm -Rf /var/www/* && \ 21 | mkdir -p /var/www/html 22 | 23 | ADD src/index.php $WORKDIR/index.php 24 | ADD src/php.ini $PHP_INI_DIR/conf.d/ 25 | -------------------------------------------------------------------------------- /src/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # Logging functions 6 | log() { 7 | local level=$1 8 | shift 9 | { set +x; } 2> /dev/null 10 | echo "[$level] $@" 11 | } 12 | 13 | info() { 14 | log "INFO" "$@" 15 | } 16 | 17 | warning() { 18 | log "WARNING" "$@" 19 | } 20 | 21 | fatal() { 22 | log "ERROR" "$@" >&2 23 | exit 1 24 | } 25 | 26 | # Banner 27 | echo "" 28 | echo "***********************************************************" 29 | echo " Starting LARAVEL PHP-FPM Container " 30 | echo "***********************************************************" 31 | 32 | # Check if the artisan file exists 33 | ARTISAN_PATH="/var/www/html/artisan" 34 | if [[ -f "$ARTISAN_PATH" ]]; then 35 | info "Artisan file found, creating Laravel supervisor config..." 36 | 37 | # Create Laravel Supervisor config 38 | SUPERVISOR_TASK="/etc/supervisor/conf.d/laravel-worker.conf" 39 | cat > "$SUPERVISOR_TASK" < -------------------------------------------------------------------------------- /src/opcache.ini: -------------------------------------------------------------------------------- 1 | [opcache] 2 | ; Determines if Zend OPCache is enabled 3 | opcache.enable=1 4 | 5 | ; Determines if Zend OPCache is enabled for the CLI version of PHP 6 | ;opcache.enable_cli=1 7 | 8 | ; The OPcache shared memory storage size. 9 | opcache.memory_consumption=512 10 | 11 | ; The amount of memory for interned strings in Mbytes. 12 | opcache.interned_strings_buffer=64 13 | 14 | ; The maximum number of keys (scripts) in the OPcache hash table. 15 | ; Only numbers between 200 and 1000000 are allowed. 16 | ;If you have multiple PHP sites on the server then consider the value 130986 17 | ; for magento 2, keep 65406 18 | opcache.max_accelerated_files=50000 19 | 20 | ; The maximum percentage of "wasted" memory until a restart is scheduled. 21 | opcache.max_wasted_percentage=15 22 | 23 | ; When this directive is enabled, the OPcache appends the current working 24 | ; directory to the script key, thus eliminating possible collisions between 25 | ; files with the same name (basename). Disabling the directive improves 26 | ; performance, but may break existing applications. 27 | ;opcache.use_cwd=1 28 | 29 | ; When disabled, you must reset the OPcache manually or restart the 30 | ; webserver for changes to the filesystem to take effect. 31 | ; For Development / testing, keep 1 32 | ; For performance / production, keep 0 33 | opcache.validate_timestamps=0 34 | 35 | ;opcache.revalidate_freq How often in seconds should the code 36 | ;cache expire and check if your code has changed. 0 means it 37 | ;checks your PHP code every single request IF YOU HAVE 38 | ;opcache.validate_timestamps ENABLED. opcache.validate_timestamps 39 | ;should not be enabled by default, as long as it's disabled then any value for opcache. 40 | ;revalidate_freq will basically be ignored. You should really only ever enable 41 | ;this during development, you don't really want to enable this setting for a production application. 42 | opcache.revalidate_freq=0 43 | 44 | ; Enables or disables file search in include_path optimization 45 | ;opcache.revalidate_path=0 46 | 47 | ; If disabled, all PHPDoc comments are dropped from the code to reduce the 48 | ; size of the optimized code. 49 | opcache.save_comments=1 50 | 51 | ; If enabled, a fast shutdown sequence is used for the accelerated code 52 | ; Depending on the used Memory Manager this may cause some incompatibilities. 53 | opcache.fast_shutdown=1 54 | 55 | ; Allow file existence override (file_exists, etc.) performance feature. 56 | ;opcache.enable_file_override=0 57 | 58 | ; A bitmask, where each bit enables or disables the appropriate OPcache 59 | ; passes 60 | ;opcache.optimization_level=0xffffffff 61 | 62 | ;opcache.inherited_hack=1 63 | ;opcache.dups_fix=0 64 | 65 | ; The location of the OPcache blacklist file (wildcards allowed). 66 | ; Each OPcache blacklist file is a text file that holds the names of files 67 | ; that should not be accelerated. The file format is to add each filename 68 | ; to a new line. The filename may be a full path or just a file prefix 69 | ; (i.e., /var/www/x blacklists all the files and directories in /var/www 70 | ; that start with 'x'). Line starting with a ; are ignored (comments). 71 | ;opcache.blacklist_filename= 72 | 73 | ; Allows exclusion of large files from being cached. By default all files 74 | ; are cached. 75 | ;opcache.max_file_size=0 76 | 77 | ; Check the cache checksum each N requests. 78 | ; The default value of "0" means that the checks are disabled. 79 | ;opcache.consistency_checks=0 80 | 81 | ; How long to wait (in seconds) for a scheduled restart to begin if the cache 82 | ; is not being accessed. 83 | ;opcache.force_restart_timeout=180 84 | 85 | ; OPcache error_log file name. Empty string assumes "stderr". 86 | ;opcache.error_log= 87 | 88 | ; All OPcache errors go to the Web server log. 89 | ; By default, only fatal errors (level 0) or errors (level 1) are logged. 90 | ; You can also enable warnings (level 2), info messages (level 3) or 91 | ; debug messages (level 4). 92 | ;opcache.log_verbosity_level=1 93 | 94 | ; Preferred Shared Memory back-end. Leave empty and let the system decide. 95 | ;opcache.preferred_memory_model= 96 | 97 | ; Protect the shared memory from unexpected writing during script execution. 98 | ; Useful for internal debugging only. 99 | ;opcache.protect_memory=0 100 | 101 | ; Allows calling OPcache API functions only from PHP scripts which path is 102 | ; started from specified string. The default "" means no restriction 103 | ;opcache.restrict_api= 104 | 105 | ; Mapping base of shared memory segments (for Windows only). All the PHP 106 | ; processes have to map shared memory into the same address space. This 107 | ; directive allows to manually fix the "Unable to reattach to base address" 108 | ; errors. 109 | opcache.mmap_base=0x20000000 110 | 111 | ; Enables and sets the second level cache directory. 112 | ; It should improve performance when SHM memory is full, at server restart or 113 | ; SHM reset. The default "" disables file based caching. 114 | ;opcache.file_cache= 115 | 116 | ; Enables or disables opcode caching in shared memory. 117 | ;opcache.file_cache_only=0 118 | 119 | ; Enables or disables checksum validation when script loaded from file cache. 120 | ;opcache.file_cache_consistency_checks=1 121 | 122 | ; Implies opcache.file_cache_only=1 for a certain process that failed to 123 | ; reattach to the shared memory (for Windows only). Explicitly enabled file 124 | ; cache is required. 125 | opcache.file_cache_fallback=1 126 | 127 | ; Enables or disables copying of PHP code (text segment) into HUGE PAGES. 128 | ; This should improve performance, but requires appropriate OS configuration. 129 | ;opcache.huge_code_pages=1 130 | 131 | ; Validate cached file permissions. 132 | ; opcache.validate_permission=0 133 | 134 | ; Prevent name collisions in chroot'ed environment. 135 | ; opcache.validate_root=0 -------------------------------------------------------------------------------- /src/php.ini: -------------------------------------------------------------------------------- 1 | date.timezone=UTC 2 | display_errors=Off 3 | log_errors=On 4 | upload_max_filesize= 30M 5 | post_max_size= 30M 6 | memory_limit = 256M 7 | -------------------------------------------------------------------------------- /src/supervisor/supervisord.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon=true 3 | user=%(ENV_USER_NAME)s 4 | logfile=/var/log/supervisor/supervisord.log 5 | logfile_maxbytes = 50MB 6 | pidfile=/tmp/supervisord.pid 7 | directory = /tmp 8 | 9 | [program:php-fpm] 10 | command=/usr/local/sbin/php-fpm 11 | numprocs=1 12 | autostart=true 13 | autorestart=true 14 | redirect_stderr=true 15 | stdout_logfile=/dev/stdout 16 | stderr_logfile=/dev/stdout 17 | stdout_logfile_maxbytes=0 18 | user=www-data 19 | priority=1 20 | 21 | 22 | [include] 23 | files = /etc/supervisor/conf.d/*.conf -------------------------------------------------------------------------------- /tests/compose.yaml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | mysql: 4 | image: mysql:8.0 5 | container_name: mysql 6 | restart: unless-stopped 7 | environment: 8 | MYSQL_DATABASE: php 9 | MYSQL_ROOT_PASSWORD: password 10 | MYSQL_PASSWORD: password 11 | MYSQL_USER: php 12 | ports: 13 | - 3306:3306 14 | php-fpm: 15 | image: jkaninda/laravel-php-fpm:latest 16 | container_name: php-fpm 17 | restart: unless-stopped 18 | #user: www-data #Use www-data user production usage 19 | depends_on: 20 | - mysql 21 | environment: 22 | DB_HOST: mysql 23 | DB_PORT: 3306 24 | DB_DATABASE: php 25 | DB_USERNAME: php 26 | DB_PASSWORD: password 27 | volumes: 28 | - ./laravel:/var/www/html 29 | #Nginx server 30 | nginx-server: 31 | image: jkaninda/nginx-fpm:stable 32 | container_name: nginx-server 33 | restart: unless-stopped 34 | ports: 35 | - 80:80 36 | volumes: 37 | - ./laravel:/var/www/html 38 | environment: 39 | - DOCUMENT_ROOT=/var/www/html/public 40 | - CLIENT_MAX_BODY_SIZE=20M 41 | - PHP_FPM_HOST=php-fpm:9000 42 | -------------------------------------------------------------------------------- /version: -------------------------------------------------------------------------------- 1 | 8.4.7 --------------------------------------------------------------------------------