mirror of
https://github.com/jkaninda/nginx-php-fpm.git
synced 2026-11-13 16:47:16 +00:00
Merge pull request #43 from jkaninda/dev
Build / docker (8.2, alpine) (push) Canceled after 0s
Build / docker (8.2, debian) (push) Canceled after 0s
Build / docker (8.3, alpine) (push) Canceled after 0s
Build / docker (8.3, debian) (push) Canceled after 0s
Build / docker (8.4, alpine) (push) Canceled after 0s
Build / docker (8.4, debian) (push) Canceled after 0s
Build / docker (8.5, alpine) (push) Canceled after 0s
Build / docker (8.5, debian) (push) Canceled after 0s
Build / legacy (./src/docker/7.2/Dockerfile, 7.2, linux/amd64, 7.2) (push) Canceled after 0s
Build / legacy (./src/docker/7.3/Dockerfile, 7.3, linux/amd64, 7.3) (push) Canceled after 0s
Build / legacy (./src/docker/7.4/Dockerfile, 7.4, linux/amd64, 7.4) (push) Canceled after 0s
Build / legacy (./src/docker/8.0/Dockerfile, 8.0, linux/amd64,linux/arm64, 8.0) (push) Canceled after 0s
Build / legacy (./src/docker/Dockerfile, 8.1, linux/amd64,linux/arm64, 8.1) (push) Canceled after 0s
Build / legacy (./src/docker/Dockerfile.alpine, 8.1, linux/amd64,linux/arm64, 8.1-alpine) (push) Canceled after 0s
Tests / integration (8.2, alpine) (push) Canceled after 0s
Tests / integration (8.2, debian) (push) Canceled after 0s
Tests / integration (8.3, alpine) (push) Canceled after 0s
Tests / integration (8.3, debian) (push) Canceled after 0s
Tests / integration (8.4, alpine) (push) Canceled after 0s
Tests / integration (8.4, debian) (push) Canceled after 0s
Tests / integration (8.5, alpine) (push) Canceled after 0s
Tests / integration (8.5, debian) (push) Canceled after 0s
Build / docker (8.2, alpine) (push) Canceled after 0s
Build / docker (8.2, debian) (push) Canceled after 0s
Build / docker (8.3, alpine) (push) Canceled after 0s
Build / docker (8.3, debian) (push) Canceled after 0s
Build / docker (8.4, alpine) (push) Canceled after 0s
Build / docker (8.4, debian) (push) Canceled after 0s
Build / docker (8.5, alpine) (push) Canceled after 0s
Build / docker (8.5, debian) (push) Canceled after 0s
Build / legacy (./src/docker/7.2/Dockerfile, 7.2, linux/amd64, 7.2) (push) Canceled after 0s
Build / legacy (./src/docker/7.3/Dockerfile, 7.3, linux/amd64, 7.3) (push) Canceled after 0s
Build / legacy (./src/docker/7.4/Dockerfile, 7.4, linux/amd64, 7.4) (push) Canceled after 0s
Build / legacy (./src/docker/8.0/Dockerfile, 8.0, linux/amd64,linux/arm64, 8.0) (push) Canceled after 0s
Build / legacy (./src/docker/Dockerfile, 8.1, linux/amd64,linux/arm64, 8.1) (push) Canceled after 0s
Build / legacy (./src/docker/Dockerfile.alpine, 8.1, linux/amd64,linux/arm64, 8.1-alpine) (push) Canceled after 0s
Tests / integration (8.2, alpine) (push) Canceled after 0s
Tests / integration (8.2, debian) (push) Canceled after 0s
Tests / integration (8.3, alpine) (push) Canceled after 0s
Tests / integration (8.3, debian) (push) Canceled after 0s
Tests / integration (8.4, alpine) (push) Canceled after 0s
Tests / integration (8.4, debian) (push) Canceled after 0s
Tests / integration (8.5, alpine) (push) Canceled after 0s
Tests / integration (8.5, debian) (push) Canceled after 0s
Modernize images and move PHP 8.1 to legacy
This commit is contained in:
24 files changed
+814
-552
No files matched your search
@@ -0,0 +1,4 @@
|
|||||||
|
.git
|
||||||
|
docker-compose.yml
|
||||||
|
laravel
|
||||||
|
tests/laravel
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: github-actions
|
||||||
|
directory: /
|
||||||
|
schedule:
|
||||||
|
interval: weekly
|
||||||
+78
-44
@@ -3,62 +3,96 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
legacy:
|
||||||
|
description: 'Also build legacy images (7.2, 7.3, 7.4, 8.0, 8.1)'
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
|
type: boolean
|
||||||
|
|
||||||
|
env:
|
||||||
|
LATEST_PHP: "8.5"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
docker:
|
docker:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
php: ["8.2", "8.3", "8.4", "8.5"]
|
||||||
|
variant: ["debian", "alpine"]
|
||||||
steps:
|
steps:
|
||||||
-
|
- uses: actions/checkout@v7
|
||||||
name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v2
|
uses: docker/setup-qemu-action@v4
|
||||||
-
|
- name: Set up Docker Buildx
|
||||||
name: Set up Docker Buildx
|
uses: docker/setup-buildx-action@v4
|
||||||
uses: docker/setup-buildx-action@v2
|
- name: Login to DockerHub
|
||||||
-
|
uses: docker/login-action@v4
|
||||||
name: Login to DockerHub
|
|
||||||
uses: docker/login-action@v2
|
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
-
|
- name: Compute tags
|
||||||
name: Build and push 8.1
|
id: meta
|
||||||
uses: docker/build-push-action@v3
|
run: |
|
||||||
|
image="${{ vars.BUILDKIT_IMAGE }}"
|
||||||
|
if [ "${{ matrix.variant }}" = "alpine" ]; then
|
||||||
|
file=./src/docker/Dockerfile.alpine
|
||||||
|
tags="${image}:${{ matrix.php }}-alpine"
|
||||||
|
[ "${{ matrix.php }}" = "${LATEST_PHP}" ] && tags="${tags},${image}:alpine"
|
||||||
|
else
|
||||||
|
file=./src/docker/Dockerfile
|
||||||
|
tags="${image}:${{ matrix.php }}"
|
||||||
|
[ "${{ matrix.php }}" = "${LATEST_PHP}" ] && tags="${tags},${image}:latest"
|
||||||
|
fi
|
||||||
|
echo "file=${file}" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "tags=${tags}" >> "$GITHUB_OUTPUT"
|
||||||
|
- name: Build and push ${{ matrix.php }} ${{ matrix.variant }}
|
||||||
|
uses: docker/build-push-action@v7
|
||||||
with:
|
with:
|
||||||
file: "./src/docker/Dockerfile"
|
context: .
|
||||||
|
file: ${{ steps.meta.outputs.file }}
|
||||||
push: true
|
push: true
|
||||||
|
pull: true
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
build-args: |
|
build-args: |
|
||||||
phpVersion=8.1
|
phpVersion=${{ matrix.php }}
|
||||||
tags: "${{ vars.BUILDKIT_IMAGE }}:8.1"
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
-
|
cache-from: type=gha,scope=${{ matrix.php }}-${{ matrix.variant }}
|
||||||
name: Build and push 8.2
|
cache-to: type=gha,mode=max,scope=${{ matrix.php }}-${{ matrix.variant }}
|
||||||
uses: docker/build-push-action@v3
|
|
||||||
|
legacy:
|
||||||
|
if: ${{ github.event_name == 'workflow_dispatch' && inputs.legacy }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- { tag: "7.2", phpVersion: "7.2", file: ./src/docker/7.2/Dockerfile, platforms: linux/amd64 }
|
||||||
|
- { tag: "7.3", phpVersion: "7.3", file: ./src/docker/7.3/Dockerfile, platforms: linux/amd64 }
|
||||||
|
- { tag: "7.4", phpVersion: "7.4", file: ./src/docker/7.4/Dockerfile, platforms: linux/amd64 }
|
||||||
|
- { tag: "8.0", phpVersion: "8.0", file: ./src/docker/8.0/Dockerfile, platforms: "linux/amd64,linux/arm64" }
|
||||||
|
- { tag: "8.1", phpVersion: "8.1", file: ./src/docker/Dockerfile, platforms: "linux/amd64,linux/arm64" }
|
||||||
|
- { tag: "8.1-alpine", phpVersion: "8.1", file: ./src/docker/Dockerfile.alpine, platforms: "linux/amd64,linux/arm64" }
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v7
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v4
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v4
|
||||||
|
- name: Login to DockerHub
|
||||||
|
uses: docker/login-action@v4
|
||||||
with:
|
with:
|
||||||
file: "./src/docker/Dockerfile"
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
push: true
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
platforms: linux/amd64,linux/arm64
|
- name: Build and push ${{ matrix.tag }}
|
||||||
build-args: |
|
uses: docker/build-push-action@v7
|
||||||
phpVersion=8.2
|
|
||||||
tags: "${{vars.BUILDKIT_IMAGE}}:8.2"
|
|
||||||
-
|
|
||||||
name: Build and push 8.3
|
|
||||||
uses: docker/build-push-action@v3
|
|
||||||
with:
|
with:
|
||||||
file: "./src/docker/Dockerfile"
|
context: .
|
||||||
|
file: ${{ matrix.file }}
|
||||||
push: true
|
push: true
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: ${{ matrix.platforms }}
|
||||||
build-args: |
|
build-args: |
|
||||||
phpVersion=8.3
|
phpVersion=${{ matrix.phpVersion }}
|
||||||
tags: |
|
tags: ${{ vars.BUILDKIT_IMAGE }}:${{ matrix.tag }}
|
||||||
"${{vars.BUILDKIT_IMAGE}}:8.3"
|
|
||||||
-
|
|
||||||
name: Build and push 8.4
|
|
||||||
uses: docker/build-push-action@v3
|
|
||||||
with:
|
|
||||||
file: "./src/docker/Dockerfile"
|
|
||||||
push: true
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
build-args: |
|
|
||||||
phpVersion=8.4
|
|
||||||
tags: |
|
|
||||||
"${{vars.BUILDKIT_IMAGE}}:8.4"
|
|
||||||
"${{vars.BUILDKIT_IMAGE}}:latest"
|
|
||||||
@@ -1,100 +0,0 @@
|
|||||||
name: Manual-build
|
|
||||||
on:
|
|
||||||
# Allows you to run this workflow manually from the Actions tab
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
docker_tag:
|
|
||||||
description: 'Docker tag'
|
|
||||||
required: true
|
|
||||||
default: 'latest'
|
|
||||||
type: string
|
|
||||||
env:
|
|
||||||
BUILDKIT_IMAGE: jkaninda/nginx-php-fpm
|
|
||||||
jobs:
|
|
||||||
docker:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v2
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v2
|
|
||||||
-
|
|
||||||
name: Login to DockerHub
|
|
||||||
uses: docker/login-action@v2
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
-
|
|
||||||
name: Build and push 7.2
|
|
||||||
uses: docker/build-push-action@v3
|
|
||||||
with:
|
|
||||||
file: "./src/docker/7.2/Dockerfile"
|
|
||||||
push: true
|
|
||||||
tags: "${{env.BUILDKIT_IMAGE}}:7.2"
|
|
||||||
-
|
|
||||||
name: Build and push 7.3
|
|
||||||
uses: docker/build-push-action@v3
|
|
||||||
with:
|
|
||||||
file: "./src/docker/7.3/Dockerfile"
|
|
||||||
push: true
|
|
||||||
tags: "${{env.BUILDKIT_IMAGE}}:7.3"
|
|
||||||
-
|
|
||||||
name: Build and push 7.4
|
|
||||||
uses: docker/build-push-action@v3
|
|
||||||
with:
|
|
||||||
file: "./src/docker/7.4/Dockerfile"
|
|
||||||
push: true
|
|
||||||
tags: "${{env.BUILDKIT_IMAGE}}:7.4"
|
|
||||||
-
|
|
||||||
name: Build and push 8.0
|
|
||||||
uses: docker/build-push-action@v3
|
|
||||||
with:
|
|
||||||
file: "./src/docker/8.0/Dockerfile"
|
|
||||||
push: true
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
tags: "${{env.BUILDKIT_IMAGE}}:8.0"
|
|
||||||
-
|
|
||||||
name: Build and push 8.1
|
|
||||||
uses: docker/build-push-action@v3
|
|
||||||
with:
|
|
||||||
file: "./src/docker/Dockerfile"
|
|
||||||
push: true
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
build-args: |
|
|
||||||
phpVersion=8.1
|
|
||||||
tags: "${{ vars.BUILDKIT_IMAGE }}:8.1"
|
|
||||||
-
|
|
||||||
name: Build and push 8.2
|
|
||||||
uses: docker/build-push-action@v3
|
|
||||||
with:
|
|
||||||
file: "./src/docker/Dockerfile"
|
|
||||||
push: true
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
build-args: |
|
|
||||||
phpVersion=8.2
|
|
||||||
tags: "${{vars.BUILDKIT_IMAGE}}:8.2"
|
|
||||||
-
|
|
||||||
name: Build and push 8.3
|
|
||||||
uses: docker/build-push-action@v3
|
|
||||||
with:
|
|
||||||
file: "./src/docker/Dockerfile"
|
|
||||||
push: true
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
build-args: |
|
|
||||||
phpVersion=8.3
|
|
||||||
tags: |
|
|
||||||
"${{vars.BUILDKIT_IMAGE}}:8.3"
|
|
||||||
"${{vars.BUILDKIT_IMAGE}}:latest"
|
|
||||||
-
|
|
||||||
name: Build and push 8.4 RC
|
|
||||||
uses: docker/build-push-action@v3
|
|
||||||
with:
|
|
||||||
file: "./src/docker/Dockerfile"
|
|
||||||
push: true
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
build-args: |
|
|
||||||
phpVersion=8.4.0RC4
|
|
||||||
tags: |
|
|
||||||
"${{vars.BUILDKIT_IMAGE}}:8.4.0RC4"
|
|
||||||
+25
-47
@@ -1,53 +1,31 @@
|
|||||||
name: Test
|
name: Tests
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
integration:
|
integration:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
php: ["8.2", "8.3", "8.4", "8.5"]
|
||||||
|
variant: ["debian", "alpine"]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v7
|
||||||
# Build the Docker image
|
- name: Set up Docker Buildx
|
||||||
- name: Build Docker Image
|
uses: docker/setup-buildx-action@v4
|
||||||
run: |
|
- name: Build Docker image
|
||||||
docker buildx build -f src/docker/Dockerfile --build-arg phpVersion=8.4 -t ${{ vars.BUILDKIT_IMAGE }}:latest --load .
|
uses: docker/build-push-action@v7
|
||||||
- name: Verify Docker images
|
with:
|
||||||
run: |
|
context: .
|
||||||
docker images
|
file: ${{ matrix.variant == 'alpine' && './src/docker/Dockerfile.alpine' || './src/docker/Dockerfile' }}
|
||||||
- name: Create Laravel project
|
load: true
|
||||||
run: |
|
build-args: |
|
||||||
composer create-project laravel/laravel laravel
|
phpVersion=${{ matrix.php }}
|
||||||
- name: Fix Permission
|
tags: nginx-php-fpm:test
|
||||||
run: chmod -R 777 ./laravel/storage
|
cache-from: type=gha,scope=${{ matrix.php }}-${{ matrix.variant }}
|
||||||
- name: Run docker-compose
|
- name: Run integration tests
|
||||||
run:
|
env:
|
||||||
cp ./tests/compose.yaml compose.yaml &&
|
IMAGE: nginx-php-fpm:test
|
||||||
docker compose -f "compose.yaml" up -d
|
run: ./tests/integration.sh
|
||||||
- name: Create script.js for K6 test
|
|
||||||
run: |
|
|
||||||
touch script.js && cat > script.js <<EOF
|
|
||||||
import http from 'k6/http';
|
|
||||||
import { sleep } from 'k6';
|
|
||||||
|
|
||||||
export default function () {
|
|
||||||
//Link
|
|
||||||
http.get('http://localhost');
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
- name: Install k6
|
|
||||||
run: |
|
|
||||||
curl https://github.com/grafana/k6/releases/download/v0.47.0/k6-v0.47.0-linux-amd64.tar.gz -L | tar xvz --strip-components 1
|
|
||||||
- name: Test with K6
|
|
||||||
run: |
|
|
||||||
./k6 run script.js
|
|
||||||
- name: Test with curl
|
|
||||||
run: |
|
|
||||||
curl -i http://localhost
|
|
||||||
- name: Waiting for database connection
|
|
||||||
run: |
|
|
||||||
while ! docker exec mysql mysql --user=root --password=password -e "status" &> /dev/null ; do
|
|
||||||
echo "Waiting for database connection..."
|
|
||||||
sleep 5
|
|
||||||
done
|
|
||||||
- name: Laravel database migration test
|
|
||||||
run: |
|
|
||||||
docker exec nginx-php-fpm php artisan migrate
|
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
.DS_Store
|
||||||
/.history
|
/.history
|
||||||
laravel
|
laravel
|
||||||
docker-compose.yml
|
docker-compose.yml
|
||||||
|
tests/modules.txt
|
||||||
@@ -1,21 +1,41 @@
|
|||||||
IMAGE_NAME?=jkaninda/nginx-php-fpm
|
IMAGE_NAME?=jkaninda/nginx-php-fpm
|
||||||
|
PHP_VERSIONS?=8.2 8.3 8.4 8.5
|
||||||
|
LATEST_PHP?=8.5
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: build
|
all: build
|
||||||
|
|
||||||
##@ Build
|
##@ Build
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
build: build-81 build-82 build-83 build-84
|
build: $(addprefix build-,$(PHP_VERSIONS))
|
||||||
.PHONY: build-80
|
|
||||||
build-80:
|
.PHONY: build-alpine
|
||||||
docker build --build-arg phpVersion=8.0 -f src/docker/8.0/Dockerfile -t ${IMAGE_NAME}:8.0 .
|
build-alpine: $(addsuffix -alpine,$(addprefix build-,$(PHP_VERSIONS)))
|
||||||
.PHONY: build-81
|
|
||||||
build-81:
|
.PHONY: build-latest
|
||||||
docker build --build-arg phpVersion=8.1 -f src/docker/Dockerfile -t ${IMAGE_NAME}:8.1 .
|
build-latest: build-$(LATEST_PHP) build-$(LATEST_PHP)-alpine
|
||||||
.PHONY: build-82
|
docker tag ${IMAGE_NAME}:$(LATEST_PHP) ${IMAGE_NAME}:latest
|
||||||
build-82:
|
docker tag ${IMAGE_NAME}:$(LATEST_PHP)-alpine ${IMAGE_NAME}:alpine
|
||||||
docker build --build-arg phpVersion=8.2 -f src/docker/Dockerfile -t ${IMAGE_NAME}:8.2 .
|
|
||||||
.PHONY: build-83
|
# Legacy images (7.2, 7.3, 7.4, 8.0). PHP 8.1 is legacy too but uses the
|
||||||
build-83:
|
# shared Dockerfiles: make build-8.1 / make build-8.1-alpine
|
||||||
docker build --build-arg phpVersion=8.3 -f src/docker/Dockerfile -t ${IMAGE_NAME}:8.3 .
|
.PHONY: build-7.2 build-7.3 build-7.4 build-8.0
|
||||||
.PHONY: build-84
|
build-7.2 build-7.3 build-7.4 build-8.0: build-%:
|
||||||
build-84:
|
docker build -f src/docker/$*/Dockerfile -t ${IMAGE_NAME}:$* .
|
||||||
docker build --build-arg phpVersion=8.4 -f src/docker/Dockerfile -t ${IMAGE_NAME}:8.4 .
|
|
||||||
|
.PHONY: build-%-alpine
|
||||||
|
build-%-alpine:
|
||||||
|
docker build --build-arg phpVersion=$* -f src/docker/Dockerfile.alpine -t ${IMAGE_NAME}:$*-alpine .
|
||||||
|
|
||||||
|
.PHONY: build-%
|
||||||
|
build-%:
|
||||||
|
docker build --build-arg phpVersion=$* -f src/docker/Dockerfile -t ${IMAGE_NAME}:$* .
|
||||||
|
|
||||||
|
##@ Test
|
||||||
|
.PHONY: test
|
||||||
|
test: build-$(LATEST_PHP)
|
||||||
|
IMAGE=${IMAGE_NAME}:$(LATEST_PHP) ./tests/integration.sh
|
||||||
|
|
||||||
|
.PHONY: test-alpine
|
||||||
|
test-alpine: build-$(LATEST_PHP)-alpine
|
||||||
|
IMAGE=${IMAGE_NAME}:$(LATEST_PHP)-alpine ./tests/integration.sh
|
||||||
@@ -10,13 +10,15 @@ A **ready-to-use container** designed for running PHP-based applications, includ
|
|||||||
|
|
||||||
#### **Features**
|
#### **Features**
|
||||||
- **PHP Application Support**: Optimized to run Laravel or any PHP-based applications.
|
- **PHP Application Support**: Optimized to run Laravel or any PHP-based applications.
|
||||||
|
- **Nginx and PHP-FPM in one container**, managed by Supervisord.
|
||||||
- **Integrated Extensions**:
|
- **Integrated Extensions**:
|
||||||
- **Database**: MySQL and PostgreSQL.
|
- **Database**: MySQL and PostgreSQL.
|
||||||
- **Caching**: Redis and Memcached.
|
- **Caching**: Redis and Memcached.
|
||||||
- **Messaging**: Kafka for event-driven architecture.
|
- **Messaging**: Kafka for event-driven architecture.
|
||||||
- **Task Scheduling**: Laravel Scheduler and Cron jobs support.
|
- **Task Scheduling**: Laravel Scheduler and Queue Worker started automatically.
|
||||||
- **Custom Configuration**: Pre-configured with sensible defaults, allowing seamless customization.
|
- **Custom Configuration**: Pre-configured with sensible defaults, tunable through environment variables.
|
||||||
- **Event Handling**: Support for advanced event-driven processes.
|
- **Debian and Alpine variants**, multi-arch (`linux/amd64`, `linux/arm64`).
|
||||||
|
- **Production-ready**: healthcheck, graceful shutdown, OPcache, logs on stdout, `supervisorctl` support.
|
||||||
- **Optimized for Microservices**: Built with modern PHP microservices in mind.
|
- **Optimized for Microservices**: Built with modern PHP microservices in mind.
|
||||||
|
|
||||||
This image is ideal for developers looking for a streamlined, high-performance solution to deploy PHP applications with essential tools already integrated.
|
This image is ideal for developers looking for a streamlined, high-performance solution to deploy PHP applications with essential tools already integrated.
|
||||||
@@ -26,35 +28,47 @@ This image is ideal for developers looking for a streamlined, high-performance s
|
|||||||
- [Docker Hub](https://hub.docker.com/r/jkaninda/nginx-php-fpm)
|
- [Docker Hub](https://hub.docker.com/r/jkaninda/nginx-php-fpm)
|
||||||
- [GitHub Repository](https://github.com/jkaninda/nginx-php-fpm)
|
- [GitHub Repository](https://github.com/jkaninda/nginx-php-fpm)
|
||||||
|
|
||||||
## **Supported PHP Versions**
|
## **Supported PHP Versions & Tags**
|
||||||
- 8.4
|
|
||||||
- 8.3
|
| PHP | Debian tag | Alpine tag |
|
||||||
- 8.2
|
|-----|------------|------------|
|
||||||
- 8.1
|
| 8.5 | `8.5`, `latest` | `8.5-alpine`, `alpine` |
|
||||||
- 8.0
|
| 8.4 | `8.4` | `8.4-alpine` |
|
||||||
- 7.4
|
| 8.3 | `8.3` | `8.3-alpine` |
|
||||||
- 7.2
|
| 8.2 | `8.2` | `8.2-alpine` |
|
||||||
|
|
||||||
|
Legacy images (PHP is end-of-life, no longer rebuilt automatically or tested): `8.1`, `8.1-alpine`, `8.0`, `7.4`, `7.3`, `7.2`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## **Specifications**
|
## **Specifications**
|
||||||
This Docker image comes pre-installed with the following:
|
|
||||||
- **PHP Extensions**:
|
### **PHP Extensions**
|
||||||
- Composer
|
- Composer 2
|
||||||
- OpenSSL
|
- OpenSSL
|
||||||
- XML
|
- XML
|
||||||
- PDO
|
- PDO (MySQL, PostgreSQL and SQLite)
|
||||||
- Rdkafka
|
- Rdkafka
|
||||||
- Redis
|
- Redis
|
||||||
- Mbstring
|
- Mbstring
|
||||||
|
- Intl
|
||||||
|
- Exif
|
||||||
- PCNTL
|
- PCNTL
|
||||||
- ZIP
|
- ZIP
|
||||||
- GD
|
- GD (FreeType, JPEG, PNG, WebP)
|
||||||
- BCMath
|
- BCMath
|
||||||
- Memcached
|
- Memcached
|
||||||
|
- Opcache
|
||||||
|
|
||||||
- **Additional Features**:
|
### **Additional Features**
|
||||||
- Laravel Cron Jobs & Scheduler
|
- Nginx
|
||||||
|
- Laravel Scheduler
|
||||||
|
- Laravel Queue Worker
|
||||||
- Supervisord
|
- Supervisord
|
||||||
- Node.js & NPM
|
- Node.js 24 LTS and NPM
|
||||||
|
- Git, Zip/Unzip, SQLite CLI
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## **Basic Usage with Docker Compose**
|
## **Basic Usage with Docker Compose**
|
||||||
|
|
||||||
@@ -62,17 +76,14 @@ This Docker image comes pre-installed with the following:
|
|||||||
```yaml
|
```yaml
|
||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
image: jkaninda/nginx-php-fpm:8.3
|
image: jkaninda/nginx-php-fpm:8.5
|
||||||
container_name: app
|
container_name: app
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
user: www-data # Optional for production
|
|
||||||
volumes:
|
volumes:
|
||||||
# Project root
|
# Project root
|
||||||
- ./src:/var/www/html
|
- ./src:/var/www/html
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "80:80"
|
||||||
networks:
|
|
||||||
- default
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### **Commands**
|
### **Commands**
|
||||||
@@ -84,27 +95,27 @@ docker compose up -d
|
|||||||
|
|
||||||
#### Create a new Laravel project:
|
#### Create a new Laravel project:
|
||||||
```sh
|
```sh
|
||||||
docker compose exec app composer create-project --prefer-dist laravel/laravel .
|
docker compose exec -u www-data app composer create-project --prefer-dist laravel/laravel .
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Generate application key:
|
#### Generate application key:
|
||||||
```sh
|
```sh
|
||||||
docker compose exec app php artisan key:generate
|
docker compose exec -u www-data app php artisan key:generate
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Create a storage symlink:
|
#### Create a storage symlink:
|
||||||
```sh
|
```sh
|
||||||
docker compose exec app php artisan storage:link
|
docker compose exec -u www-data app php artisan storage:link
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Fix storage and cache permissions:
|
#### Fix storage and cache permissions:
|
||||||
```sh
|
```sh
|
||||||
docker compose exec app chmod -R 777 storage bootstrap/cache
|
docker compose exec app chown -R www-data:www-data storage bootstrap/cache
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Run Laravel migrations:
|
#### Run Laravel migrations:
|
||||||
```sh
|
```sh
|
||||||
docker compose exec app php artisan migrate
|
docker compose exec -u www-data app php artisan migrate
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Access the container shell:
|
#### Access the container shell:
|
||||||
@@ -112,37 +123,91 @@ docker compose exec app php artisan migrate
|
|||||||
docker exec -it app bash
|
docker exec -it app bash
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Run a one-off command (Nginx and PHP-FPM are not started):
|
||||||
|
```sh
|
||||||
|
docker run --rm -v "$PWD:/var/www/html" jkaninda/nginx-php-fpm composer install
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Restart the queue workers after a deployment:
|
||||||
|
```sh
|
||||||
|
docker compose exec app supervisorctl restart Laravel-worker:*
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## **Advanced Nginx PHP-FPM Setup**
|
## **Environment Variables**
|
||||||
|
|
||||||
|
### Nginx
|
||||||
|
|
||||||
|
| Variable | Default | Description |
|
||||||
|
|----------|---------|-------------|
|
||||||
|
| `DOCUMENT_ROOT` | `$APP_DIR/public` if it exists, otherwise `$APP_DIR` | Nginx web root |
|
||||||
|
| `DOMAIN` | `_` | Nginx `server_name` |
|
||||||
|
| `CLIENT_MAX_BODY_SIZE` | `15M` | Nginx `client_max_body_size` |
|
||||||
|
|
||||||
|
### Laravel
|
||||||
|
|
||||||
|
| Variable | Default | Description |
|
||||||
|
|----------|---------|-------------|
|
||||||
|
| `LARAVEL_SCHEDULER_ENABLED` | `true` | Run `php artisan schedule:run` every minute |
|
||||||
|
| `LARAVEL_QUEUE_WORKER_ENABLED` | `true` | Run `php artisan queue:work` |
|
||||||
|
| `LARAVEL_QUEUE_OPTIONS` | `--sleep=3 --tries=3` | Options passed to `queue:work` (e.g. `redis --queue=high,default`) |
|
||||||
|
| `LARAVEL_PROCS_NUMBER` | `1` | Number of queue worker processes |
|
||||||
|
| `APP_DIR` | `/var/www/html` | Application directory (where `artisan` is looked up) |
|
||||||
|
|
||||||
|
The scheduler and queue worker are only started when an `artisan` file is found in `APP_DIR`.
|
||||||
|
|
||||||
|
### PHP
|
||||||
|
|
||||||
|
| Variable | Default |
|
||||||
|
|----------|---------|
|
||||||
|
| `PHP_MEMORY_LIMIT` | `256M` |
|
||||||
|
| `PHP_UPLOAD_MAX_FILESIZE` | `80M` |
|
||||||
|
| `PHP_POST_MAX_SIZE` | `80M` |
|
||||||
|
| `PHP_MAX_EXECUTION_TIME` | `30` |
|
||||||
|
| `PHP_DATE_TIMEZONE` | `UTC` |
|
||||||
|
| `PHP_DISPLAY_ERRORS` | `Off` |
|
||||||
|
|
||||||
|
### OPcache
|
||||||
|
|
||||||
|
| Variable | Default | Description |
|
||||||
|
|----------|---------|-------------|
|
||||||
|
| `PHP_OPCACHE_ENABLE` | `1` | |
|
||||||
|
| `PHP_OPCACHE_ENABLE_CLI` | `0` | |
|
||||||
|
| `PHP_OPCACHE_MEMORY_CONSUMPTION` | `512` | MB |
|
||||||
|
| `PHP_OPCACHE_MAX_ACCELERATED_FILES` | `50000` | |
|
||||||
|
| `PHP_OPCACHE_VALIDATE_TIMESTAMPS` | `0` | Set to `1` in development so code changes are picked up |
|
||||||
|
| `PHP_OPCACHE_REVALIDATE_FREQ` | `0` | |
|
||||||
|
|
||||||
|
### PHP-FPM
|
||||||
|
|
||||||
|
| Variable | Default |
|
||||||
|
|----------|---------|
|
||||||
|
| `PHP_FPM_PM` | `dynamic` |
|
||||||
|
| `PHP_FPM_PM_MAX_CHILDREN` | `20` |
|
||||||
|
| `PHP_FPM_PM_START_SERVERS` | `2` |
|
||||||
|
| `PHP_FPM_PM_MIN_SPARE_SERVERS` | `1` |
|
||||||
|
| `PHP_FPM_PM_MAX_SPARE_SERVERS` | `3` |
|
||||||
|
| `PHP_FPM_PM_MAX_REQUESTS` | `500` |
|
||||||
|
|
||||||
|
Container environment variables (e.g. `DB_HOST`, `APP_KEY`) are passed to PHP-FPM workers (`clear_env = no`).
|
||||||
|
|
||||||
|
### Development example
|
||||||
|
|
||||||
### **Extended `docker-compose.yml` Example**
|
|
||||||
```yaml
|
```yaml
|
||||||
version: '3'
|
|
||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
image: jkaninda/nginx-php-fpm
|
image: jkaninda/nginx-php-fpm:8.5
|
||||||
container_name: app
|
|
||||||
restart: unless-stopped
|
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "80:80"
|
||||||
volumes:
|
|
||||||
# Project root
|
|
||||||
- ./:/var/www/html
|
|
||||||
- ~/.ssh:/root/.ssh # Use private CVS if needed
|
|
||||||
# Optional custom PHP config
|
|
||||||
# - ./php.ini:/usr/local/etc/php/conf.d/php.ini
|
|
||||||
environment:
|
environment:
|
||||||
- APP_ENV=development # or production
|
PHP_OPCACHE_VALIDATE_TIMESTAMPS: 1
|
||||||
- LARAVEL_PROCS_NUMBER=2 # Optional: Queue worker processes
|
PHP_DISPLAY_ERRORS: "On"
|
||||||
# - CLIENT_MAX_BODY_SIZE=20M # Optional
|
CLIENT_MAX_BODY_SIZE: 20M
|
||||||
# - DOMAIN=example.com # Optional
|
LARAVEL_QUEUE_OPTIONS: "redis --sleep=3 --tries=3"
|
||||||
- DOCUMENT_ROOT=/var/www/html # Optional
|
LARAVEL_PROCS_NUMBER: 2
|
||||||
```
|
volumes:
|
||||||
|
- ./:/var/www/html
|
||||||
### **Default Web Root**
|
|
||||||
```
|
|
||||||
/var/www/html
|
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -151,7 +216,7 @@ services:
|
|||||||
|
|
||||||
### **Dockerfile**
|
### **Dockerfile**
|
||||||
```Dockerfile
|
```Dockerfile
|
||||||
FROM jkaninda/nginx-php-fpm:8.3
|
FROM jkaninda/nginx-php-fpm:8.5
|
||||||
# Copy Laravel project files
|
# Copy Laravel project files
|
||||||
COPY . /var/www/html
|
COPY . /var/www/html
|
||||||
# Storage Volume
|
# Storage Volume
|
||||||
@@ -161,23 +226,32 @@ WORKDIR /var/www/html
|
|||||||
|
|
||||||
# Fix permissions
|
# Fix permissions
|
||||||
RUN chown -R www-data:www-data /var/www/html
|
RUN chown -R www-data:www-data /var/www/html
|
||||||
|
|
||||||
USER www-data
|
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## **Custom Nginx Configuration**
|
## **Custom Nginx Configuration**
|
||||||
|
|
||||||
To enable custom Nginx configurations, use the following files:
|
To use custom Nginx configurations, add the following files to your project:
|
||||||
- `/var/www/html/conf/nginx/nginx.conf`
|
- `conf/nginx/nginx.conf`: replaces `/etc/nginx/nginx.conf`
|
||||||
- `/var/www/html/conf/nginx/nginx-site.conf`
|
- `conf/nginx/nginx-site.conf`: replaces the generated server block. PHP-FPM listens on `127.0.0.1:9000`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## **Custom PHP Configuration**
|
||||||
|
|
||||||
|
Most common settings can be changed with [environment variables](#environment-variables).
|
||||||
|
For anything else, either:
|
||||||
|
|
||||||
|
- mount or copy your own `.ini` file into `/usr/local/etc/php/conf.d/`, or
|
||||||
|
- place a `php.ini` file at `conf/php/php.ini` in your project; it is copied into `conf.d` at startup.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## **Supervisord Integration**
|
## **Supervisord Integration**
|
||||||
|
|
||||||
Supervisord can be used to manage tasks or processes within the container.
|
Supervisord can be used to manage tasks or processes within the container.
|
||||||
|
Place your programs in `conf/worker/supervisor.conf` in your project, or mount them into `/etc/supervisor/conf.d/`.
|
||||||
|
|
||||||
### **Example Configuration for Kafka Consumer**
|
### **Example Configuration for Kafka Consumer**
|
||||||
```conf
|
```conf
|
||||||
@@ -196,16 +270,23 @@ stdout_logfile=/var/www/html/storage/logs/kafka.log
|
|||||||
|
|
||||||
## **Fixing Storage Permissions**
|
## **Fixing Storage Permissions**
|
||||||
|
|
||||||
If you encounter storage permission issues, run the following commands:
|
`www-data` has UID/GID `1000` in both Debian and Alpine variants. If you encounter permission issues, run:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
docker compose exec php-fpm /bin/bash
|
docker compose exec app chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache
|
||||||
|
docker compose exec app chmod -R 775 /var/www/html/storage
|
||||||
```
|
```
|
||||||
|
|
||||||
Then inside the container:
|
To match your host user, rebuild with `--build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g)`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## **Building & Testing Locally**
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
chown -R www-data:www-data /var/www/html/
|
make build-8.5 # Debian image
|
||||||
chmod -R 775 /var/www/html/storage
|
make build-8.5-alpine # Alpine image
|
||||||
|
make test # Integration test (Laravel + MySQL)
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -236,5 +317,3 @@ Whether you're managing internal APIs or exposing public endpoints, **Goma Gatew
|
|||||||
|
|
||||||
## ⭐️ **Support the Project**
|
## ⭐️ **Support the Project**
|
||||||
If this project helped you, do not skip on giving it a star. Thanks!
|
If this project helped you, do not skip on giving it a star. Thanks!
|
||||||
|
|
||||||
|
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
if [ $# -eq 0 ]
|
# Usage: ./build.sh [php-version] (default: 8.5)
|
||||||
then
|
# ./build.sh 8.4-alpine
|
||||||
tag='latest'
|
set -e
|
||||||
else
|
tag=${1:-8.5}
|
||||||
tag=$1
|
version=${tag%-alpine}
|
||||||
fi
|
|
||||||
if [ $tag != 'latest' ]
|
|
||||||
then
|
|
||||||
echo 'Build from tag'
|
|
||||||
docker build -f src/docker/${tag}/Dockerfile -t jkaninda/nginx-php-fpm:$tag .
|
|
||||||
else
|
|
||||||
echo 'Build latest'
|
|
||||||
docker build -f src/docker/8.3/Dockerfile -t jkaninda/nginx-php-fpm:$tag .
|
|
||||||
|
|
||||||
|
if [ -f "src/docker/${version}/Dockerfile" ]; then
|
||||||
|
echo "Build legacy image ${tag}"
|
||||||
|
docker build -f "src/docker/${version}/Dockerfile" -t "jkaninda/nginx-php-fpm:${tag}" .
|
||||||
|
elif [ "${tag}" != "${version}" ]; then
|
||||||
|
echo "Build ${tag}"
|
||||||
|
docker build --build-arg phpVersion="${version}" -f src/docker/Dockerfile.alpine -t "jkaninda/nginx-php-fpm:${tag}" .
|
||||||
|
else
|
||||||
|
echo "Build ${tag}"
|
||||||
|
docker build --build-arg phpVersion="${version}" -f src/docker/Dockerfile -t "jkaninda/nginx-php-fpm:${tag}" .
|
||||||
fi
|
fi
|
||||||
docker compose up -d --force-recreate
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
|
|
||||||
server {
|
|
||||||
listen 80 default_server;
|
|
||||||
listen [::]:80 default_server;
|
|
||||||
server_name _;
|
|
||||||
# Add index.php to setup Nginx, PHP & PHP-FPM config
|
|
||||||
index index.php index.html index.htm index.nginx-debian.html; error_log /var/log/nginx/error.log;
|
|
||||||
access_log /var/log/nginx/access.log;
|
|
||||||
root /var/www/html;
|
|
||||||
# pass PHP scripts on Nginx to FastCGI (PHP-FPM) server
|
|
||||||
location ~ \.php$ {
|
|
||||||
try_files $uri =404;
|
|
||||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
|
||||||
# Nginx php-fpm config:
|
|
||||||
fastcgi_pass 127.0.0.1:9000;
|
|
||||||
fastcgi_index index.php;
|
|
||||||
include fastcgi_params;
|
|
||||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
|
||||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
|
||||||
|
|
||||||
}
|
|
||||||
client_max_body_size 15M;
|
|
||||||
server_tokens off;
|
|
||||||
|
|
||||||
# Hide PHP headers
|
|
||||||
fastcgi_hide_header X-Powered-By;
|
|
||||||
fastcgi_hide_header X-CF-Powered-By;
|
|
||||||
fastcgi_hide_header X-Runtime;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
try_files $uri $uri/ /index.php?$query_string;
|
|
||||||
gzip_static on;
|
|
||||||
}
|
|
||||||
# deny access to Apache .htaccess on Nginx with PHP,
|
|
||||||
# if Apache and Nginx document roots concur
|
|
||||||
location ~ /\.ht {deny all;}
|
|
||||||
location ~ /\.svn/ {deny all;}
|
|
||||||
location ~ /\.git/ {deny all;}
|
|
||||||
location ~ /\.hg/ {deny all;}
|
|
||||||
location ~ /\.bzr/ {deny all;}
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,19 @@
|
|||||||
FROM php:7.2-fpm
|
FROM php:7.2-fpm
|
||||||
ARG WORKDIR=/var/www/html
|
ARG WORKDIR=/var/www/html
|
||||||
ENV DOCUMENT_ROOT=${WORKDIR}
|
|
||||||
ENV LARAVEL_PROCS_NUMBER=1
|
ENV LARAVEL_PROCS_NUMBER=1
|
||||||
|
ENV APP_DIR=/var/www/html \
|
||||||
|
PHP_DATE_TIMEZONE=UTC \
|
||||||
|
PHP_DISPLAY_ERRORS=Off \
|
||||||
|
PHP_MEMORY_LIMIT=256M \
|
||||||
|
PHP_UPLOAD_MAX_FILESIZE=80M \
|
||||||
|
PHP_POST_MAX_SIZE=80M \
|
||||||
|
PHP_MAX_EXECUTION_TIME=30 \
|
||||||
|
PHP_OPCACHE_ENABLE=1 \
|
||||||
|
PHP_OPCACHE_ENABLE_CLI=0 \
|
||||||
|
PHP_OPCACHE_MEMORY_CONSUMPTION=512 \
|
||||||
|
PHP_OPCACHE_MAX_ACCELERATED_FILES=50000 \
|
||||||
|
PHP_OPCACHE_VALIDATE_TIMESTAMPS=0 \
|
||||||
|
PHP_OPCACHE_REVALIDATE_FREQ=0
|
||||||
ENV DOMAIN=_
|
ENV DOMAIN=_
|
||||||
ENV CLIENT_MAX_BODY_SIZE=15M
|
ENV CLIENT_MAX_BODY_SIZE=15M
|
||||||
ENV NODE_VERSION=17.x
|
ENV NODE_VERSION=17.x
|
||||||
@@ -84,7 +96,6 @@ RUN rm -rf /etc/nginx/sites-available/default
|
|||||||
RUN rm -rf /etc/nginx/nginx.conf
|
RUN rm -rf /etc/nginx/nginx.conf
|
||||||
|
|
||||||
COPY src/nginx.conf /etc/nginx/nginx.conf
|
COPY src/nginx.conf /etc/nginx/nginx.conf
|
||||||
COPY src/default.conf /etc/nginx/conf.d/
|
|
||||||
|
|
||||||
RUN usermod -u ${USER_ID} ${USER_NAME}
|
RUN usermod -u ${USER_ID} ${USER_NAME}
|
||||||
RUN groupmod -g ${USER_ID} ${GROUP_NAME}
|
RUN groupmod -g ${USER_ID} ${GROUP_NAME}
|
||||||
|
|||||||
@@ -1,7 +1,19 @@
|
|||||||
FROM php:7.3-fpm
|
FROM php:7.3-fpm
|
||||||
ARG WORKDIR=/var/www/html
|
ARG WORKDIR=/var/www/html
|
||||||
ENV DOCUMENT_ROOT=${WORKDIR}
|
|
||||||
ENV LARAVEL_PROCS_NUMBER=1
|
ENV LARAVEL_PROCS_NUMBER=1
|
||||||
|
ENV APP_DIR=/var/www/html \
|
||||||
|
PHP_DATE_TIMEZONE=UTC \
|
||||||
|
PHP_DISPLAY_ERRORS=Off \
|
||||||
|
PHP_MEMORY_LIMIT=256M \
|
||||||
|
PHP_UPLOAD_MAX_FILESIZE=80M \
|
||||||
|
PHP_POST_MAX_SIZE=80M \
|
||||||
|
PHP_MAX_EXECUTION_TIME=30 \
|
||||||
|
PHP_OPCACHE_ENABLE=1 \
|
||||||
|
PHP_OPCACHE_ENABLE_CLI=0 \
|
||||||
|
PHP_OPCACHE_MEMORY_CONSUMPTION=512 \
|
||||||
|
PHP_OPCACHE_MAX_ACCELERATED_FILES=50000 \
|
||||||
|
PHP_OPCACHE_VALIDATE_TIMESTAMPS=0 \
|
||||||
|
PHP_OPCACHE_REVALIDATE_FREQ=0
|
||||||
ENV DOMAIN=_
|
ENV DOMAIN=_
|
||||||
ENV CLIENT_MAX_BODY_SIZE=15M
|
ENV CLIENT_MAX_BODY_SIZE=15M
|
||||||
ENV NODE_VERSION=17.x
|
ENV NODE_VERSION=17.x
|
||||||
@@ -85,7 +97,6 @@ RUN rm -rf /etc/nginx/sites-available/default
|
|||||||
RUN rm -rf /etc/nginx/nginx.conf
|
RUN rm -rf /etc/nginx/nginx.conf
|
||||||
|
|
||||||
COPY src/nginx.conf /etc/nginx/nginx.conf
|
COPY src/nginx.conf /etc/nginx/nginx.conf
|
||||||
COPY src/default.conf /etc/nginx/conf.d/
|
|
||||||
|
|
||||||
RUN usermod -u ${USER_ID} ${USER_NAME}
|
RUN usermod -u ${USER_ID} ${USER_NAME}
|
||||||
RUN groupmod -g ${USER_ID} ${GROUP_NAME}
|
RUN groupmod -g ${USER_ID} ${GROUP_NAME}
|
||||||
|
|||||||
@@ -1,7 +1,19 @@
|
|||||||
FROM php:7.4-fpm
|
FROM php:7.4-fpm
|
||||||
ARG WORKDIR=/var/www/html
|
ARG WORKDIR=/var/www/html
|
||||||
ENV DOCUMENT_ROOT=${WORKDIR}
|
|
||||||
ENV LARAVEL_PROCS_NUMBER=1
|
ENV LARAVEL_PROCS_NUMBER=1
|
||||||
|
ENV APP_DIR=/var/www/html \
|
||||||
|
PHP_DATE_TIMEZONE=UTC \
|
||||||
|
PHP_DISPLAY_ERRORS=Off \
|
||||||
|
PHP_MEMORY_LIMIT=256M \
|
||||||
|
PHP_UPLOAD_MAX_FILESIZE=80M \
|
||||||
|
PHP_POST_MAX_SIZE=80M \
|
||||||
|
PHP_MAX_EXECUTION_TIME=30 \
|
||||||
|
PHP_OPCACHE_ENABLE=1 \
|
||||||
|
PHP_OPCACHE_ENABLE_CLI=0 \
|
||||||
|
PHP_OPCACHE_MEMORY_CONSUMPTION=512 \
|
||||||
|
PHP_OPCACHE_MAX_ACCELERATED_FILES=50000 \
|
||||||
|
PHP_OPCACHE_VALIDATE_TIMESTAMPS=0 \
|
||||||
|
PHP_OPCACHE_REVALIDATE_FREQ=0
|
||||||
ENV DOMAIN=_
|
ENV DOMAIN=_
|
||||||
ENV CLIENT_MAX_BODY_SIZE=15M
|
ENV CLIENT_MAX_BODY_SIZE=15M
|
||||||
ENV NODE_VERSION=17.x
|
ENV NODE_VERSION=17.x
|
||||||
@@ -84,7 +96,6 @@ RUN rm -rf /etc/nginx/sites-available/default
|
|||||||
RUN rm -rf /etc/nginx/nginx.conf
|
RUN rm -rf /etc/nginx/nginx.conf
|
||||||
|
|
||||||
COPY src/nginx.conf /etc/nginx/nginx.conf
|
COPY src/nginx.conf /etc/nginx/nginx.conf
|
||||||
COPY src/default.conf /etc/nginx/conf.d/
|
|
||||||
|
|
||||||
RUN usermod -u ${USER_ID} ${USER_NAME}
|
RUN usermod -u ${USER_ID} ${USER_NAME}
|
||||||
RUN groupmod -g ${USER_ID} ${GROUP_NAME}
|
RUN groupmod -g ${USER_ID} ${GROUP_NAME}
|
||||||
|
|||||||
@@ -1,7 +1,19 @@
|
|||||||
FROM php:8.0-fpm
|
FROM php:8.0-fpm
|
||||||
ARG WORKDIR=/var/www/html
|
ARG WORKDIR=/var/www/html
|
||||||
ENV DOCUMENT_ROOT=${WORKDIR}
|
|
||||||
ENV LARAVEL_PROCS_NUMBER=1
|
ENV LARAVEL_PROCS_NUMBER=1
|
||||||
|
ENV APP_DIR=/var/www/html \
|
||||||
|
PHP_DATE_TIMEZONE=UTC \
|
||||||
|
PHP_DISPLAY_ERRORS=Off \
|
||||||
|
PHP_MEMORY_LIMIT=256M \
|
||||||
|
PHP_UPLOAD_MAX_FILESIZE=80M \
|
||||||
|
PHP_POST_MAX_SIZE=80M \
|
||||||
|
PHP_MAX_EXECUTION_TIME=30 \
|
||||||
|
PHP_OPCACHE_ENABLE=1 \
|
||||||
|
PHP_OPCACHE_ENABLE_CLI=0 \
|
||||||
|
PHP_OPCACHE_MEMORY_CONSUMPTION=512 \
|
||||||
|
PHP_OPCACHE_MAX_ACCELERATED_FILES=50000 \
|
||||||
|
PHP_OPCACHE_VALIDATE_TIMESTAMPS=0 \
|
||||||
|
PHP_OPCACHE_REVALIDATE_FREQ=0
|
||||||
ENV DOMAIN=_
|
ENV DOMAIN=_
|
||||||
ENV CLIENT_MAX_BODY_SIZE=15M
|
ENV CLIENT_MAX_BODY_SIZE=15M
|
||||||
ENV NODE_VERSION=17.x
|
ENV NODE_VERSION=17.x
|
||||||
@@ -96,7 +108,6 @@ RUN rm -rf /etc/nginx/sites-available/default
|
|||||||
RUN rm -rf /etc/nginx/nginx.conf
|
RUN rm -rf /etc/nginx/nginx.conf
|
||||||
|
|
||||||
COPY src/nginx.conf /etc/nginx/nginx.conf
|
COPY src/nginx.conf /etc/nginx/nginx.conf
|
||||||
COPY src/default.conf /etc/nginx/conf.d/
|
|
||||||
|
|
||||||
RUN usermod -u ${USER_ID} ${USER_NAME}
|
RUN usermod -u ${USER_ID} ${USER_NAME}
|
||||||
RUN groupmod -g ${USER_ID} ${GROUP_NAME}
|
RUN groupmod -g ${USER_ID} ${GROUP_NAME}
|
||||||
|
|||||||
+87
-101
@@ -1,123 +1,109 @@
|
|||||||
ARG phpVersion=8.3-dev
|
# syntax=docker/dockerfile:1
|
||||||
|
ARG phpVersion=8.5
|
||||||
|
FROM composer:2 AS composer
|
||||||
|
|
||||||
FROM php:${phpVersion}-fpm
|
FROM php:${phpVersion}-fpm
|
||||||
ARG WORKDIR=/var/www/html
|
ARG WORKDIR=/var/www/html
|
||||||
ENV DOCUMENT_ROOT=${WORKDIR}
|
|
||||||
ENV LARAVEL_PROCS_NUMBER=1
|
|
||||||
ENV DOMAIN=_
|
|
||||||
ENV CLIENT_MAX_BODY_SIZE=15M
|
|
||||||
ENV NODE_VERSION=20.x
|
|
||||||
ARG GROUP_ID=1000
|
ARG GROUP_ID=1000
|
||||||
ARG USER_ID=1000
|
ARG USER_ID=1000
|
||||||
ENV USER_NAME=www-data
|
|
||||||
ARG GROUP_NAME=www-data
|
ARG GROUP_NAME=www-data
|
||||||
# Install system dependencies
|
ARG NODE_MAJOR=24
|
||||||
RUN apt-get update && apt-get install -y \
|
|
||||||
git \
|
|
||||||
curl \
|
|
||||||
libfreetype6-dev \
|
|
||||||
libjpeg62-turbo-dev \
|
|
||||||
libmemcached-dev \
|
|
||||||
libzip-dev \
|
|
||||||
libpng-dev \
|
|
||||||
libonig-dev \
|
|
||||||
libxml2-dev \
|
|
||||||
librdkafka-dev \
|
|
||||||
libpq-dev \
|
|
||||||
openssh-server \
|
|
||||||
zip \
|
|
||||||
unzip \
|
|
||||||
supervisor \
|
|
||||||
sqlite3 \
|
|
||||||
nano \
|
|
||||||
cron
|
|
||||||
|
|
||||||
RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION} | bash -
|
LABEL org.opencontainers.image.title="nginx-php-fpm" \
|
||||||
# Install Node
|
org.opencontainers.image.description="Nginx and PHP-FPM image for Laravel and PHP applications" \
|
||||||
RUN apt-get install -y nodejs
|
org.opencontainers.image.source="https://github.com/jkaninda/nginx-php-fpm" \
|
||||||
# Install nginx
|
org.opencontainers.image.licenses="MIT" \
|
||||||
RUN apt-get update && apt-get install -y nginx
|
org.opencontainers.image.authors="Jonas Kaninda"
|
||||||
|
|
||||||
# Clear cache
|
ENV APP_DIR=${WORKDIR} \
|
||||||
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
|
USER_NAME=www-data \
|
||||||
# Install Kafka
|
NODE_MAJOR=${NODE_MAJOR} \
|
||||||
RUN git clone https://github.com/arnaud-lb/php-rdkafka.git\
|
DOMAIN=_ \
|
||||||
&& cd php-rdkafka \
|
CLIENT_MAX_BODY_SIZE=15M \
|
||||||
&& phpize \
|
LARAVEL_PROCS_NUMBER=1 \
|
||||||
&& ./configure \
|
LARAVEL_QUEUE_WORKER_ENABLED=true \
|
||||||
&& make all -j 5 \
|
LARAVEL_QUEUE_OPTIONS="--sleep=3 --tries=3" \
|
||||||
&& make install
|
LARAVEL_SCHEDULER_ENABLED=true \
|
||||||
|
PHP_DATE_TIMEZONE=UTC \
|
||||||
|
PHP_DISPLAY_ERRORS=Off \
|
||||||
|
PHP_MEMORY_LIMIT=256M \
|
||||||
|
PHP_UPLOAD_MAX_FILESIZE=80M \
|
||||||
|
PHP_POST_MAX_SIZE=80M \
|
||||||
|
PHP_MAX_EXECUTION_TIME=30 \
|
||||||
|
PHP_OPCACHE_ENABLE=1 \
|
||||||
|
PHP_OPCACHE_ENABLE_CLI=0 \
|
||||||
|
PHP_OPCACHE_MEMORY_CONSUMPTION=512 \
|
||||||
|
PHP_OPCACHE_MAX_ACCELERATED_FILES=50000 \
|
||||||
|
PHP_OPCACHE_VALIDATE_TIMESTAMPS=0 \
|
||||||
|
PHP_OPCACHE_REVALIDATE_FREQ=0 \
|
||||||
|
PHP_FPM_PM=dynamic \
|
||||||
|
PHP_FPM_PM_MAX_CHILDREN=20 \
|
||||||
|
PHP_FPM_PM_START_SERVERS=2 \
|
||||||
|
PHP_FPM_PM_MIN_SPARE_SERVERS=1 \
|
||||||
|
PHP_FPM_PM_MAX_SPARE_SERVERS=3 \
|
||||||
|
PHP_FPM_PM_MAX_REQUESTS=500
|
||||||
|
|
||||||
# Install Rdkafka and enable it
|
# Runtime tools, Nginx and Node.js
|
||||||
RUN docker-php-ext-enable rdkafka \
|
RUN set -eux; \
|
||||||
&& cd .. \
|
apt-get update; \
|
||||||
&& rm -rf /php-rdkafka
|
apt-get install -y --no-install-recommends \
|
||||||
|
ca-certificates curl gnupg git openssh-client unzip zip \
|
||||||
|
nginx supervisor cron sqlite3 nano; \
|
||||||
|
mkdir -p /etc/apt/keyrings; \
|
||||||
|
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg; \
|
||||||
|
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODE_MAJOR}.x nodistro main" > /etc/apt/sources.list.d/nodesource.list; \
|
||||||
|
apt-get update; \
|
||||||
|
apt-get install -y --no-install-recommends nodejs; \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Install PHP extensions zip, mbstring, exif, bcmath, intl
|
# PHP extensions (build dependencies are purged, runtime libraries are kept)
|
||||||
RUN docker-php-ext-configure gd --with-freetype --with-jpeg
|
RUN set -eux; \
|
||||||
RUN docker-php-ext-install zip mbstring exif pcntl bcmath -j$(nproc) gd intl
|
savedAptMark="$(apt-mark showmanual)"; \
|
||||||
|
apt-get update; \
|
||||||
|
apt-get install -y --no-install-recommends \
|
||||||
|
libfreetype6-dev libjpeg62-turbo-dev libpng-dev libwebp-dev \
|
||||||
|
libicu-dev libmemcached-dev libonig-dev libpq-dev librdkafka-dev \
|
||||||
|
libxml2-dev libzip-dev zlib1g-dev; \
|
||||||
|
docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp; \
|
||||||
|
docker-php-ext-install -j"$(nproc)" bcmath exif gd intl mbstring pcntl pdo_mysql pdo_pgsql zip; \
|
||||||
|
pecl install redis memcached rdkafka; \
|
||||||
|
docker-php-ext-enable redis memcached rdkafka; \
|
||||||
|
# OPcache is always compiled in since PHP 8.5
|
||||||
|
if ! php -m | grep -qi '^zend opcache$'; then docker-php-ext-install opcache; fi; \
|
||||||
|
apt-mark auto '.*' > /dev/null; \
|
||||||
|
apt-mark manual $savedAptMark > /dev/null; \
|
||||||
|
find /usr/local -type f \( -executable -o -name '*.so' \) -exec ldd '{}' ';' 2>/dev/null \
|
||||||
|
| awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); printf "*%s\n", so }' \
|
||||||
|
| sort -u | xargs -r dpkg-query --search | awk -F: '!/^diversion/ { print $1 }' | sort -u | xargs -r apt-mark manual; \
|
||||||
|
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
|
||||||
|
rm -rf /var/lib/apt/lists/* /tmp/pear ~/.pearrc; \
|
||||||
|
! php -m 2>&1 | grep -iE 'warning|unable to load'
|
||||||
|
|
||||||
# Install Redis and enable it
|
COPY --from=composer /usr/bin/composer /usr/local/bin/composer
|
||||||
RUN pecl install redis && docker-php-ext-enable redis
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Install the php memcached extension
|
|
||||||
RUN pecl install memcached && docker-php-ext-enable memcached
|
|
||||||
|
|
||||||
# Install the PHP pdo_mysql extention
|
|
||||||
RUN docker-php-ext-install pdo_mysql
|
|
||||||
|
|
||||||
# Install the PHP pdo_pgsql extention
|
|
||||||
RUN docker-php-ext-install pdo_pgsql
|
|
||||||
|
|
||||||
# Install PHP Opcache extention
|
|
||||||
RUN docker-php-ext-install opcache
|
|
||||||
|
|
||||||
# Install Composer
|
|
||||||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
|
||||||
|
|
||||||
# Set working directory
|
|
||||||
WORKDIR $WORKDIR
|
WORKDIR $WORKDIR
|
||||||
|
|
||||||
RUN rm -Rf /var/www/* && \
|
RUN rm -Rf /var/www/* /etc/nginx/sites-enabled/default /etc/nginx/sites-available/default /etc/nginx/conf.d/default.conf && \
|
||||||
mkdir -p /var/www/html
|
mkdir -p ${WORKDIR} /etc/supervisor/conf.d /var/log/supervisor /var/log/nginx /var/cache/nginx /etc/nginx/conf.d
|
||||||
|
|
||||||
ADD src/index.php $WORKDIR/index.php
|
|
||||||
ADD src/php.ini $PHP_INI_DIR/conf.d/
|
|
||||||
ADD src/opcache.ini $PHP_INI_DIR/conf.d/
|
|
||||||
ADD src/supervisor/supervisord.conf /etc/supervisor/supervisord.conf
|
|
||||||
|
|
||||||
COPY src/entrypoint.sh /usr/local/bin/
|
|
||||||
RUN chmod +x /usr/local/bin/entrypoint.sh && \
|
|
||||||
ln -s /usr/local/bin/entrypoint.sh /
|
|
||||||
|
|
||||||
RUN rm -rf /etc/nginx/conf.d/default.conf && \
|
|
||||||
rm -rf /etc/nginx/sites-enabled/default && \
|
|
||||||
rm -rf /etc/nginx/sites-available/default && \
|
|
||||||
rm -rf /etc/nginx/nginx.conf
|
|
||||||
|
|
||||||
|
COPY src/index.php $WORKDIR/index.php
|
||||||
|
COPY src/php.ini src/opcache.ini $PHP_INI_DIR/conf.d/
|
||||||
|
COPY src/php-fpm.d/zz-nginx-php-fpm.conf /usr/local/etc/php-fpm.d/zz-nginx-php-fpm.conf
|
||||||
COPY src/nginx.conf /etc/nginx/nginx.conf
|
COPY src/nginx.conf /etc/nginx/nginx.conf
|
||||||
COPY src/default.conf /etc/nginx/conf.d/
|
COPY src/supervisor/supervisord.conf /etc/supervisor/supervisord.conf
|
||||||
|
COPY --chmod=755 src/entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||||
|
RUN ln -s /usr/local/bin/entrypoint.sh /entrypoint.sh
|
||||||
|
|
||||||
RUN usermod -u ${USER_ID} ${USER_NAME} && \
|
RUN usermod -u ${USER_ID} ${USER_NAME} && \
|
||||||
groupmod -g ${USER_ID} ${GROUP_NAME}
|
groupmod -g ${GROUP_ID} ${GROUP_NAME} && \
|
||||||
|
|
||||||
RUN mkdir -p /var/log/supervisor /var/log/nginx /var/cache/nginx
|
|
||||||
|
|
||||||
RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \
|
|
||||||
chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \
|
|
||||||
chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \
|
|
||||||
chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/ && \
|
|
||||||
touch /var/run/nginx.pid && \
|
touch /var/run/nginx.pid && \
|
||||||
chown -R $USER_NAME:$USER_NAME /var/cache/nginx && \
|
chown -R ${USER_NAME}:${GROUP_NAME} /var/www /var/log /tmp $PHP_INI_DIR/conf.d \
|
||||||
chown -R $USER_NAME:$USER_NAME /var/lib/nginx/ && \
|
/etc/supervisor/conf.d /etc/nginx/nginx.conf /etc/nginx/conf.d \
|
||||||
chown -R $USER_NAME:$USER_NAME /etc/nginx/nginx.conf && \
|
/var/cache/nginx /var/lib/nginx /var/run/nginx.pid
|
||||||
chown -R $USER_NAME:$USER_NAME /var/run/nginx.pid && \
|
|
||||||
chown -R $USER_NAME:$USER_NAME /var/log/supervisor && \
|
|
||||||
chown -R $USER_NAME:$USER_NAME /etc/nginx/conf.d/ && \
|
|
||||||
chown -R ${USER_NAME}:${GROUP_NAME} /tmp
|
|
||||||
|
|
||||||
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --start-interval=2s --retries=3 \
|
||||||
|
CMD php -r 'exit(@fsockopen("127.0.0.1", 9000) && @fsockopen("127.0.0.1", 80) ? 0 : 1);'
|
||||||
|
|
||||||
#USER ${USER_NAME}
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
ENTRYPOINT ["entrypoint.sh"]
|
ENTRYPOINT ["entrypoint.sh"]
|
||||||
|
CMD ["entrypoint"]
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
ARG phpVersion=8.5
|
||||||
|
FROM composer:2 AS composer
|
||||||
|
|
||||||
|
FROM php:${phpVersion}-fpm-alpine
|
||||||
|
ARG WORKDIR=/var/www/html
|
||||||
|
ARG GROUP_ID=1000
|
||||||
|
ARG USER_ID=1000
|
||||||
|
ARG GROUP_NAME=www-data
|
||||||
|
|
||||||
|
LABEL org.opencontainers.image.title="nginx-php-fpm" \
|
||||||
|
org.opencontainers.image.description="Nginx and PHP-FPM image for Laravel and PHP applications (Alpine)" \
|
||||||
|
org.opencontainers.image.source="https://github.com/jkaninda/nginx-php-fpm" \
|
||||||
|
org.opencontainers.image.licenses="MIT" \
|
||||||
|
org.opencontainers.image.authors="Jonas Kaninda"
|
||||||
|
|
||||||
|
ENV APP_DIR=${WORKDIR} \
|
||||||
|
USER_NAME=www-data \
|
||||||
|
DOMAIN=_ \
|
||||||
|
CLIENT_MAX_BODY_SIZE=15M \
|
||||||
|
LARAVEL_PROCS_NUMBER=1 \
|
||||||
|
LARAVEL_QUEUE_WORKER_ENABLED=true \
|
||||||
|
LARAVEL_QUEUE_OPTIONS="--sleep=3 --tries=3" \
|
||||||
|
LARAVEL_SCHEDULER_ENABLED=true \
|
||||||
|
PHP_DATE_TIMEZONE=UTC \
|
||||||
|
PHP_DISPLAY_ERRORS=Off \
|
||||||
|
PHP_MEMORY_LIMIT=256M \
|
||||||
|
PHP_UPLOAD_MAX_FILESIZE=80M \
|
||||||
|
PHP_POST_MAX_SIZE=80M \
|
||||||
|
PHP_MAX_EXECUTION_TIME=30 \
|
||||||
|
PHP_OPCACHE_ENABLE=1 \
|
||||||
|
PHP_OPCACHE_ENABLE_CLI=0 \
|
||||||
|
PHP_OPCACHE_MEMORY_CONSUMPTION=512 \
|
||||||
|
PHP_OPCACHE_MAX_ACCELERATED_FILES=50000 \
|
||||||
|
PHP_OPCACHE_VALIDATE_TIMESTAMPS=0 \
|
||||||
|
PHP_OPCACHE_REVALIDATE_FREQ=0 \
|
||||||
|
PHP_FPM_PM=dynamic \
|
||||||
|
PHP_FPM_PM_MAX_CHILDREN=20 \
|
||||||
|
PHP_FPM_PM_START_SERVERS=2 \
|
||||||
|
PHP_FPM_PM_MIN_SPARE_SERVERS=1 \
|
||||||
|
PHP_FPM_PM_MAX_SPARE_SERVERS=3 \
|
||||||
|
PHP_FPM_PM_MAX_REQUESTS=500
|
||||||
|
|
||||||
|
# Runtime tools, Nginx and Node.js
|
||||||
|
RUN apk add --no-cache bash curl git openssh-client unzip zip nginx supervisor sqlite nano nodejs npm
|
||||||
|
|
||||||
|
# PHP extensions (build dependencies are removed, runtime libraries are kept)
|
||||||
|
RUN set -eux; \
|
||||||
|
apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \
|
||||||
|
freetype-dev libjpeg-turbo-dev libpng-dev libwebp-dev \
|
||||||
|
icu-dev libmemcached-dev oniguruma-dev libpq-dev librdkafka-dev \
|
||||||
|
libxml2-dev libzip-dev zlib-dev cyrus-sasl-dev linux-headers; \
|
||||||
|
docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp; \
|
||||||
|
docker-php-ext-install -j"$(nproc)" bcmath exif gd intl mbstring pcntl pdo_mysql pdo_pgsql zip; \
|
||||||
|
pecl install redis memcached rdkafka; \
|
||||||
|
docker-php-ext-enable redis memcached rdkafka; \
|
||||||
|
# OPcache is always compiled in since PHP 8.5
|
||||||
|
if ! php -m | grep -qi '^zend opcache$'; then docker-php-ext-install opcache; fi; \
|
||||||
|
runDeps="$( \
|
||||||
|
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \
|
||||||
|
| tr ',' '\n' | sort -u \
|
||||||
|
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
|
||||||
|
)"; \
|
||||||
|
apk add --no-cache --virtual .php-ext-rundeps $runDeps; \
|
||||||
|
apk del --no-network .build-deps; \
|
||||||
|
rm -rf /tmp/pear ~/.pearrc; \
|
||||||
|
! php -m 2>&1 | grep -iE 'warning|unable to load'
|
||||||
|
|
||||||
|
COPY --from=composer /usr/bin/composer /usr/local/bin/composer
|
||||||
|
|
||||||
|
WORKDIR $WORKDIR
|
||||||
|
|
||||||
|
RUN rm -Rf /var/www/* /etc/nginx/http.d/default.conf && \
|
||||||
|
mkdir -p ${WORKDIR} /etc/supervisor/conf.d /var/log/supervisor /var/log/nginx /var/cache/nginx /etc/nginx/conf.d
|
||||||
|
|
||||||
|
COPY src/index.php $WORKDIR/index.php
|
||||||
|
COPY src/php.ini src/opcache.ini $PHP_INI_DIR/conf.d/
|
||||||
|
COPY src/php-fpm.d/zz-nginx-php-fpm.conf /usr/local/etc/php-fpm.d/zz-nginx-php-fpm.conf
|
||||||
|
COPY src/nginx.conf /etc/nginx/nginx.conf
|
||||||
|
COPY src/supervisor/supervisord.conf /etc/supervisor/supervisord.conf
|
||||||
|
COPY --chmod=755 src/entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||||
|
RUN ln -s /usr/local/bin/entrypoint.sh /entrypoint.sh && \
|
||||||
|
ln -sf /etc/supervisor/supervisord.conf /etc/supervisord.conf
|
||||||
|
|
||||||
|
RUN apk add --no-cache --virtual .user-deps shadow && \
|
||||||
|
usermod -u ${USER_ID} ${USER_NAME} && \
|
||||||
|
groupmod -g ${GROUP_ID} ${GROUP_NAME} && \
|
||||||
|
apk del --no-network .user-deps && \
|
||||||
|
touch /var/run/nginx.pid && \
|
||||||
|
chown -R ${USER_NAME}:${GROUP_NAME} /var/www /var/log /tmp $PHP_INI_DIR/conf.d \
|
||||||
|
/etc/supervisor/conf.d /etc/nginx/nginx.conf /etc/nginx/conf.d \
|
||||||
|
/var/cache/nginx /var/lib/nginx /var/run/nginx.pid
|
||||||
|
|
||||||
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --start-interval=2s --retries=3 \
|
||||||
|
CMD php -r 'exit(@fsockopen("127.0.0.1", 9000) && @fsockopen("127.0.0.1", 80) ? 0 : 1);'
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
ENTRYPOINT ["entrypoint.sh"]
|
||||||
|
CMD ["entrypoint"]
|
||||||
+135
-82
@@ -2,70 +2,84 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "***********************************************************"
|
|
||||||
echo " Starting NGINX PHP-FPM Docker Container "
|
|
||||||
echo "***********************************************************"
|
|
||||||
|
|
||||||
# Logging functions
|
# Logging functions
|
||||||
info() { echo "[INFO] $*"; }
|
log() {
|
||||||
warning() { echo "[WARNING] $*"; }
|
level=$1
|
||||||
fatal() { echo "[ERROR] $*" >&2; exit 1; }
|
shift
|
||||||
|
echo "[$level] $*"
|
||||||
ARTISAN_FILE="/var/www/html/artisan"
|
|
||||||
SUPERVISOR_CONF_DIR="/etc/supervisor/conf.d"
|
|
||||||
NGINX_CONF_DIR="/etc/nginx/conf.d"
|
|
||||||
CUSTOM_NGINX_CONF="/var/www/html/conf/nginx"
|
|
||||||
CUSTOM_SUPERVISOR_CONF="/var/www/html/conf/worker/supervisor.conf"
|
|
||||||
DOCUMENT_ROOT="/var/www/html/public"
|
|
||||||
|
|
||||||
# Laravel Supervisor Setup
|
|
||||||
setup_laravel_supervisor() {
|
|
||||||
info "Artisan file found, creating Laravel supervisor config"
|
|
||||||
export DOCUMENT_ROOT
|
|
||||||
|
|
||||||
cat > "$SUPERVISOR_CONF_DIR/laravel-worker.conf" <<EOF
|
|
||||||
[program:Laravel-scheduler]
|
|
||||||
process_name=%(program_name)s_%(process_num)02d
|
|
||||||
command=/bin/sh -c "while true; do (php /var/www/html/artisan schedule:run --verbose --no-interaction &); sleep 60; done"
|
|
||||||
autostart=true
|
|
||||||
autorestart=true
|
|
||||||
numprocs=1
|
|
||||||
user=$USER_NAME
|
|
||||||
stdout_logfile=/var/log/laravel_scheduler.out.log
|
|
||||||
redirect_stderr=true
|
|
||||||
|
|
||||||
[program:Laravel-worker]
|
|
||||||
process_name=%(program_name)s_%(process_num)02d
|
|
||||||
command=php /var/www/html/artisan queue:work --sleep=3 --tries=3
|
|
||||||
autostart=true
|
|
||||||
autorestart=true
|
|
||||||
numprocs=$LARAVEL_PROCS_NUMBER
|
|
||||||
user=$USER_NAME
|
|
||||||
redirect_stderr=true
|
|
||||||
stdout_logfile=/var/log/laravel_worker.log
|
|
||||||
EOF
|
|
||||||
|
|
||||||
info "Laravel supervisor config created"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Nginx Config Setup
|
info() {
|
||||||
setup_nginx_config() {
|
log "INFO" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
warning() {
|
||||||
|
log "WARNING" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
fatal() {
|
||||||
|
log "ERROR" "$@" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
is_true() {
|
||||||
|
case "$1" in
|
||||||
|
1|true|TRUE|True|yes|YES|on|ON) return 0 ;;
|
||||||
|
*) return 1 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
APP_DIR="${APP_DIR:-/var/www/html}"
|
||||||
|
USER_NAME="${USER_NAME:-www-data}"
|
||||||
|
DOMAIN="${DOMAIN:-_}"
|
||||||
|
CLIENT_MAX_BODY_SIZE="${CLIENT_MAX_BODY_SIZE:-15M}"
|
||||||
|
LARAVEL_PROCS_NUMBER="${LARAVEL_PROCS_NUMBER:-1}"
|
||||||
|
LARAVEL_QUEUE_OPTIONS="${LARAVEL_QUEUE_OPTIONS:---sleep=3 --tries=3}"
|
||||||
|
|
||||||
|
# Default to the Laravel public directory when it exists
|
||||||
|
if [ -z "$DOCUMENT_ROOT" ]; then
|
||||||
|
if [ -d "$APP_DIR/public" ]; then
|
||||||
|
DOCUMENT_ROOT="$APP_DIR/public"
|
||||||
|
else
|
||||||
|
DOCUMENT_ROOT="$APP_DIR"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
NGINX_CONF_DIR="/etc/nginx/conf.d"
|
||||||
|
CUSTOM_NGINX_CONF="$APP_DIR/conf/nginx"
|
||||||
|
CUSTOM_SUPERVISOR_CONF="$APP_DIR/conf/worker/supervisor.conf"
|
||||||
|
SUPERVISOR_CONF_DIR="/etc/supervisor/conf.d"
|
||||||
|
|
||||||
|
# Check if custom php.ini file exists
|
||||||
|
PHP_INI_SOURCE="$APP_DIR/conf/php/php.ini"
|
||||||
|
PHP_INI_TARGET="$PHP_INI_DIR/conf.d/php.ini"
|
||||||
|
|
||||||
|
if [ -f "$PHP_INI_SOURCE" ]; then
|
||||||
|
cp "$PHP_INI_SOURCE" "$PHP_INI_TARGET"
|
||||||
|
info "Custom php.ini file found and copied to $PHP_INI_TARGET"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Run any other command (e.g. "php artisan migrate", "composer install", "bash")
|
||||||
|
if [ $# -gt 0 ] && [ "$1" != "entrypoint" ] && [ "$1" != "supervisord" ]; then
|
||||||
|
exec "$@"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Banner
|
||||||
|
echo ""
|
||||||
|
echo "***********************************************************"
|
||||||
|
echo " Starting NGINX PHP-FPM Container "
|
||||||
|
echo "***********************************************************"
|
||||||
|
|
||||||
|
# Nginx configuration
|
||||||
if [ -f "$CUSTOM_NGINX_CONF/nginx.conf" ]; then
|
if [ -f "$CUSTOM_NGINX_CONF/nginx.conf" ]; then
|
||||||
cp "$CUSTOM_NGINX_CONF/nginx.conf" /etc/nginx/nginx.conf
|
cp "$CUSTOM_NGINX_CONF/nginx.conf" /etc/nginx/nginx.conf
|
||||||
info "Using custom nginx.conf"
|
info "Using custom nginx.conf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "$CUSTOM_NGINX_CONF/nginx-site.conf" ]; then
|
if [ -f "$CUSTOM_NGINX_CONF/nginx-site.conf" ]; then
|
||||||
info "Custom nginx site config found"
|
|
||||||
rm -f "$NGINX_CONF_DIR/default.conf"
|
|
||||||
cp "$CUSTOM_NGINX_CONF/nginx-site.conf" "$NGINX_CONF_DIR/default.conf"
|
cp "$CUSTOM_NGINX_CONF/nginx-site.conf" "$NGINX_CONF_DIR/default.conf"
|
||||||
info "Start nginx with custom server config..."
|
info "Using custom nginx site config $CUSTOM_NGINX_CONF/nginx-site.conf"
|
||||||
else
|
else
|
||||||
info "nginx-site.conf not found"
|
|
||||||
info "If you want to use custom configs, create it at $CUSTOM_NGINX_CONF/nginx-site.conf"
|
|
||||||
info "Start nginx with default config..."
|
|
||||||
|
|
||||||
cat > "$NGINX_CONF_DIR/default.conf" <<EOF
|
cat > "$NGINX_CONF_DIR/default.conf" <<EOF
|
||||||
server {
|
server {
|
||||||
listen 80 default_server;
|
listen 80 default_server;
|
||||||
@@ -74,18 +88,8 @@ server {
|
|||||||
root $DOCUMENT_ROOT;
|
root $DOCUMENT_ROOT;
|
||||||
index index.php index.html index.htm;
|
index index.php index.html index.htm;
|
||||||
|
|
||||||
error_log /var/log/nginx/error.log;
|
access_log /dev/stdout;
|
||||||
access_log /var/log/nginx/access.log;
|
error_log /dev/stderr warn;
|
||||||
|
|
||||||
location ~ \.php\$ {
|
|
||||||
try_files \$uri =404;
|
|
||||||
fastcgi_split_path_info ^(.+\.php)(/.+)\$;
|
|
||||||
fastcgi_pass 127.0.0.1:9000;
|
|
||||||
fastcgi_index index.php;
|
|
||||||
include fastcgi_params;
|
|
||||||
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
|
|
||||||
fastcgi_param PATH_INFO \$fastcgi_path_info;
|
|
||||||
}
|
|
||||||
|
|
||||||
client_max_body_size $CLIENT_MAX_BODY_SIZE;
|
client_max_body_size $CLIENT_MAX_BODY_SIZE;
|
||||||
server_tokens off;
|
server_tokens off;
|
||||||
@@ -99,29 +103,78 @@ server {
|
|||||||
gzip_static on;
|
gzip_static on;
|
||||||
}
|
}
|
||||||
|
|
||||||
location ~ \.css\$ { add_header Content-Type text/css; }
|
location ~ \.php\$ {
|
||||||
location ~ \.js\$ { add_header Content-Type application/x-javascript; }
|
try_files \$uri =404;
|
||||||
|
fastcgi_split_path_info ^(.+\.php)(/.+)\$;
|
||||||
|
fastcgi_pass 127.0.0.1:9000;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
include fastcgi_params;
|
||||||
|
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
|
||||||
|
fastcgi_param PATH_INFO \$fastcgi_path_info;
|
||||||
|
}
|
||||||
|
|
||||||
location ~ /\.ht { deny all; }
|
location ~ /\.(ht|svn|git|hg|bzr) { deny all; }
|
||||||
location ~ /\.(svn|git|hg|bzr)/ { deny all; }
|
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
info "Nginx serving $DOCUMENT_ROOT (server_name $DOMAIN)"
|
||||||
|
info "To use a custom config, create $CUSTOM_NGINX_CONF/nginx-site.conf"
|
||||||
fi
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
# Load custom supervisor config if exists
|
# Check if the artisan file exists
|
||||||
load_custom_supervisor_config() {
|
ARTISAN_PATH="$APP_DIR/artisan"
|
||||||
|
SUPERVISOR_TASK="$SUPERVISOR_CONF_DIR/laravel-worker.conf"
|
||||||
|
if [ -f "$ARTISAN_PATH" ]; then
|
||||||
|
info "Artisan file found, creating Laravel supervisor config..."
|
||||||
|
: > "$SUPERVISOR_TASK"
|
||||||
|
|
||||||
|
if is_true "${LARAVEL_SCHEDULER_ENABLED:-true}"; then
|
||||||
|
cat >> "$SUPERVISOR_TASK" <<EOF
|
||||||
|
[program:Laravel-scheduler]
|
||||||
|
process_name=%(program_name)s_%(process_num)02d
|
||||||
|
command=/bin/sh -c "while true; do php $ARTISAN_PATH schedule:run --verbose --no-interaction & sleep 60; done"
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
numprocs=1
|
||||||
|
user=$USER_NAME
|
||||||
|
stdout_logfile=/var/log/laravel_scheduler.out.log
|
||||||
|
redirect_stderr=true
|
||||||
|
|
||||||
|
EOF
|
||||||
|
info "Laravel scheduler enabled"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if is_true "${LARAVEL_QUEUE_WORKER_ENABLED:-true}"; then
|
||||||
|
cat >> "$SUPERVISOR_TASK" <<EOF
|
||||||
|
[program:Laravel-worker]
|
||||||
|
process_name=%(program_name)s_%(process_num)02d
|
||||||
|
command=php $ARTISAN_PATH queue:work $LARAVEL_QUEUE_OPTIONS
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
; Keep retrying while the database/queue backend is not ready yet
|
||||||
|
startretries=20
|
||||||
|
stopwaitsecs=3600
|
||||||
|
numprocs=$LARAVEL_PROCS_NUMBER
|
||||||
|
user=$USER_NAME
|
||||||
|
redirect_stderr=true
|
||||||
|
stdout_logfile=/var/log/laravel_worker.log
|
||||||
|
EOF
|
||||||
|
info "Laravel queue worker enabled ($LARAVEL_PROCS_NUMBER process(es))"
|
||||||
|
fi
|
||||||
|
|
||||||
|
info "Laravel supervisor config created at $SUPERVISOR_TASK"
|
||||||
|
else
|
||||||
|
rm -f "$SUPERVISOR_TASK" 2>/dev/null || true
|
||||||
|
info "Artisan file not found at $ARTISAN_PATH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Custom supervisor programs
|
||||||
if [ -f "$CUSTOM_SUPERVISOR_CONF" ]; then
|
if [ -f "$CUSTOM_SUPERVISOR_CONF" ]; then
|
||||||
info "Custom supervisor config found"
|
|
||||||
cp "$CUSTOM_SUPERVISOR_CONF" "$SUPERVISOR_CONF_DIR/supervisor.conf"
|
cp "$CUSTOM_SUPERVISOR_CONF" "$SUPERVISOR_CONF_DIR/supervisor.conf"
|
||||||
|
info "Custom supervisor config found and copied"
|
||||||
fi
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
# Main Execution
|
# Start Supervisor (programs drop privileges to $USER_NAME themselves)
|
||||||
[ -f "$ARTISAN_FILE" ] && setup_laravel_supervisor || info "artisan file not found"
|
if [ "$(id -u)" = "0" ]; then
|
||||||
|
exec supervisord -c /etc/supervisor/supervisord.conf -u root
|
||||||
setup_nginx_config
|
fi
|
||||||
load_custom_supervisor_config
|
exec supervisord -c /etc/supervisor/supervisord.conf
|
||||||
|
|
||||||
# Start Supervisor
|
|
||||||
supervisord -c /etc/supervisor/supervisord.conf
|
|
||||||
+4
-2
@@ -1,8 +1,10 @@
|
|||||||
user www-data;
|
user www-data;
|
||||||
worker_processes auto;
|
worker_processes auto;
|
||||||
error_log /var/log/nginx/error.log crit;
|
error_log /dev/stderr warn;
|
||||||
pid /var/run/nginx.pid;
|
pid /var/run/nginx.pid;
|
||||||
|
# Dynamic modules (Debian / Alpine)
|
||||||
include /etc/nginx/modules-enabled/*.conf;
|
include /etc/nginx/modules-enabled/*.conf;
|
||||||
|
include /etc/nginx/modules/*.conf;
|
||||||
|
|
||||||
events {
|
events {
|
||||||
worker_connections 1024;
|
worker_connections 1024;
|
||||||
@@ -43,7 +45,7 @@ http {
|
|||||||
gzip_min_length 512;
|
gzip_min_length 512;
|
||||||
gzip_comp_level 6;
|
gzip_comp_level 6;
|
||||||
gzip_buffers 8 64k;
|
gzip_buffers 8 64k;
|
||||||
gzip_types text/plain text/xml text/css text/js application/x-javascript application/xml image/png image/x-icon image/gif image/jpeg image/svg+xml application/xml+rss text/javascript application/atom+xml application/javascript application/json application/x-font-ttf font/opentype;
|
gzip_types text/plain text/xml text/css text/js application/x-javascript application/xml image/x-icon image/svg+xml application/xml+rss text/javascript application/atom+xml application/javascript application/json application/x-font-ttf font/opentype;
|
||||||
|
|
||||||
# Proxy settings
|
# Proxy settings
|
||||||
proxy_redirect off;
|
proxy_redirect off;
|
||||||
|
|||||||
+8
-12
@@ -1,12 +1,12 @@
|
|||||||
[opcache]
|
[opcache]
|
||||||
; Determines if Zend OPCache is enabled
|
; Determines if Zend OPCache is enabled
|
||||||
opcache.enable=1
|
opcache.enable=${PHP_OPCACHE_ENABLE}
|
||||||
|
|
||||||
; Determines if Zend OPCache is enabled for the CLI version of PHP
|
; Determines if Zend OPCache is enabled for the CLI version of PHP
|
||||||
;opcache.enable_cli=1
|
opcache.enable_cli=${PHP_OPCACHE_ENABLE_CLI}
|
||||||
|
|
||||||
; The OPcache shared memory storage size.
|
; The OPcache shared memory storage size.
|
||||||
opcache.memory_consumption=512
|
opcache.memory_consumption=${PHP_OPCACHE_MEMORY_CONSUMPTION}
|
||||||
|
|
||||||
; The amount of memory for interned strings in Mbytes.
|
; The amount of memory for interned strings in Mbytes.
|
||||||
opcache.interned_strings_buffer=64
|
opcache.interned_strings_buffer=64
|
||||||
@@ -15,7 +15,7 @@ opcache.interned_strings_buffer=64
|
|||||||
; Only numbers between 200 and 1000000 are allowed.
|
; Only numbers between 200 and 1000000 are allowed.
|
||||||
;If you have multiple PHP sites on the server then consider the value 130986
|
;If you have multiple PHP sites on the server then consider the value 130986
|
||||||
; for magento 2, keep 65406
|
; for magento 2, keep 65406
|
||||||
opcache.max_accelerated_files=50000
|
opcache.max_accelerated_files=${PHP_OPCACHE_MAX_ACCELERATED_FILES}
|
||||||
|
|
||||||
; The maximum percentage of "wasted" memory until a restart is scheduled.
|
; The maximum percentage of "wasted" memory until a restart is scheduled.
|
||||||
opcache.max_wasted_percentage=15
|
opcache.max_wasted_percentage=15
|
||||||
@@ -30,7 +30,7 @@ opcache.max_wasted_percentage=15
|
|||||||
; webserver for changes to the filesystem to take effect.
|
; webserver for changes to the filesystem to take effect.
|
||||||
; For Development / testing, keep 1
|
; For Development / testing, keep 1
|
||||||
; For performance / production, keep 0
|
; For performance / production, keep 0
|
||||||
opcache.validate_timestamps=0
|
opcache.validate_timestamps=${PHP_OPCACHE_VALIDATE_TIMESTAMPS}
|
||||||
|
|
||||||
;opcache.revalidate_freq How often in seconds should the code
|
;opcache.revalidate_freq How often in seconds should the code
|
||||||
;cache expire and check if your code has changed. 0 means it
|
;cache expire and check if your code has changed. 0 means it
|
||||||
@@ -39,7 +39,7 @@ opcache.validate_timestamps=0
|
|||||||
;should not be enabled by default, as long as it's disabled then any value for opcache.
|
;should not be enabled by default, as long as it's disabled then any value for opcache.
|
||||||
;revalidate_freq will basically be ignored. You should really only ever enable
|
;revalidate_freq will basically be ignored. You should really only ever enable
|
||||||
;this during development, you don't really want to enable this setting for a production application.
|
;this during development, you don't really want to enable this setting for a production application.
|
||||||
opcache.revalidate_freq=0
|
opcache.revalidate_freq=${PHP_OPCACHE_REVALIDATE_FREQ}
|
||||||
|
|
||||||
; Enables or disables file search in include_path optimization
|
; Enables or disables file search in include_path optimization
|
||||||
;opcache.revalidate_path=0
|
;opcache.revalidate_path=0
|
||||||
@@ -48,10 +48,6 @@ opcache.revalidate_freq=0
|
|||||||
; size of the optimized code.
|
; size of the optimized code.
|
||||||
opcache.save_comments=1
|
opcache.save_comments=1
|
||||||
|
|
||||||
; If enabled, a fast shutdown sequence is used for the accelerated code
|
|
||||||
; Depending on the used Memory Manager this may cause some incompatibilities.
|
|
||||||
opcache.fast_shutdown=1
|
|
||||||
|
|
||||||
; Allow file existence override (file_exists, etc.) performance feature.
|
; Allow file existence override (file_exists, etc.) performance feature.
|
||||||
;opcache.enable_file_override=0
|
;opcache.enable_file_override=0
|
||||||
|
|
||||||
@@ -106,7 +102,7 @@ opcache.fast_shutdown=1
|
|||||||
; processes have to map shared memory into the same address space. This
|
; processes have to map shared memory into the same address space. This
|
||||||
; directive allows to manually fix the "Unable to reattach to base address"
|
; directive allows to manually fix the "Unable to reattach to base address"
|
||||||
; errors.
|
; errors.
|
||||||
opcache.mmap_base=0x20000000
|
;opcache.mmap_base=
|
||||||
|
|
||||||
; Enables and sets the second level cache directory.
|
; Enables and sets the second level cache directory.
|
||||||
; It should improve performance when SHM memory is full, at server restart or
|
; It should improve performance when SHM memory is full, at server restart or
|
||||||
@@ -122,7 +118,7 @@ opcache.mmap_base=0x20000000
|
|||||||
; Implies opcache.file_cache_only=1 for a certain process that failed to
|
; Implies opcache.file_cache_only=1 for a certain process that failed to
|
||||||
; reattach to the shared memory (for Windows only). Explicitly enabled file
|
; reattach to the shared memory (for Windows only). Explicitly enabled file
|
||||||
; cache is required.
|
; cache is required.
|
||||||
opcache.file_cache_fallback=1
|
;opcache.file_cache_fallback=1
|
||||||
|
|
||||||
; Enables or disables copying of PHP code (text segment) into HUGE PAGES.
|
; Enables or disables copying of PHP code (text segment) into HUGE PAGES.
|
||||||
; This should improve performance, but requires appropriate OS configuration.
|
; This should improve performance, but requires appropriate OS configuration.
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
[www]
|
||||||
|
; Expose container environment variables (DB_HOST, APP_KEY, ...) to PHP workers
|
||||||
|
clear_env = no
|
||||||
|
|
||||||
|
; Process manager, tunable through PHP_FPM_* environment variables
|
||||||
|
pm = ${PHP_FPM_PM}
|
||||||
|
pm.max_children = ${PHP_FPM_PM_MAX_CHILDREN}
|
||||||
|
pm.start_servers = ${PHP_FPM_PM_START_SERVERS}
|
||||||
|
pm.min_spare_servers = ${PHP_FPM_PM_MIN_SPARE_SERVERS}
|
||||||
|
pm.max_spare_servers = ${PHP_FPM_PM_MAX_SPARE_SERVERS}
|
||||||
|
pm.max_requests = ${PHP_FPM_PM_MAX_REQUESTS}
|
||||||
|
|
||||||
|
; Health endpoint for FastCGI probes
|
||||||
|
ping.path = /ping
|
||||||
|
ping.response = pong
|
||||||
+8
-5
@@ -1,6 +1,9 @@
|
|||||||
date.timezone=UTC
|
; Values can be overridden with environment variables (see README)
|
||||||
display_errors=Off
|
date.timezone=${PHP_DATE_TIMEZONE}
|
||||||
|
display_errors=${PHP_DISPLAY_ERRORS}
|
||||||
log_errors=On
|
log_errors=On
|
||||||
upload_max_filesize= 80M
|
expose_php=Off
|
||||||
post_max_size= 80M
|
upload_max_filesize=${PHP_UPLOAD_MAX_FILESIZE}
|
||||||
memory_limit = 256M
|
post_max_size=${PHP_POST_MAX_SIZE}
|
||||||
|
memory_limit=${PHP_MEMORY_LIMIT}
|
||||||
|
max_execution_time=${PHP_MAX_EXECUTION_TIME}
|
||||||
@@ -1,32 +1,41 @@
|
|||||||
[supervisord]
|
[supervisord]
|
||||||
nodaemon=true
|
nodaemon=true
|
||||||
user=www-data
|
|
||||||
logfile=/var/log/supervisor/supervisord.log
|
logfile=/var/log/supervisor/supervisord.log
|
||||||
logfile_maxbytes = 50MB
|
logfile_maxbytes = 50MB
|
||||||
pidfile=/tmp/supervisord.pid
|
pidfile=/tmp/supervisord.pid
|
||||||
directory = /tmp
|
directory = /tmp
|
||||||
|
|
||||||
|
[unix_http_server]
|
||||||
|
file=/tmp/supervisor.sock
|
||||||
|
chmod=0700
|
||||||
|
|
||||||
|
[rpcinterface:supervisor]
|
||||||
|
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
|
||||||
|
|
||||||
|
[supervisorctl]
|
||||||
|
serverurl=unix:///tmp/supervisor.sock
|
||||||
|
|
||||||
[program:php-fpm]
|
[program:php-fpm]
|
||||||
command=/usr/local/sbin/php-fpm
|
command=/usr/local/sbin/php-fpm --nodaemonize
|
||||||
numprocs=1
|
numprocs=1
|
||||||
autostart=true
|
autostart=true
|
||||||
autorestart=true
|
autorestart=true
|
||||||
stderr_logfile=/var/log/supervisor/php-fpm.err.log
|
redirect_stderr=true
|
||||||
stdout_logfile=/var/log/supervisor/php-fpm.out.log
|
stdout_logfile=/dev/stdout
|
||||||
user=www-data
|
stdout_logfile_maxbytes=0
|
||||||
priority=1
|
priority=1
|
||||||
|
stopsignal=QUIT
|
||||||
|
|
||||||
[program:nginx]
|
[program:nginx]
|
||||||
command=/usr/sbin/nginx -g "daemon off;"
|
command=/usr/sbin/nginx -g "daemon off;"
|
||||||
numprocs=1
|
numprocs=1
|
||||||
autostart=true
|
autostart=true
|
||||||
autorestart=true
|
autorestart=true
|
||||||
stderr_logfile=/var/log/nginx/nginx.err.log
|
redirect_stderr=true
|
||||||
stdout_logfile=/var/log/nginx/nginx.out.log
|
stdout_logfile=/dev/stdout
|
||||||
logfile_maxbytes = 50MB
|
stdout_logfile_maxbytes=0
|
||||||
user=www-data
|
|
||||||
priority=2
|
priority=2
|
||||||
|
stopsignal=QUIT
|
||||||
|
|
||||||
[include]
|
[include]
|
||||||
files = /etc/supervisor/conf.d/*.conf
|
files = /etc/supervisor/conf.d/*.conf
|
||||||
+12
-8
@@ -1,7 +1,6 @@
|
|||||||
version: '3'
|
|
||||||
services:
|
services:
|
||||||
mysql:
|
mysql:
|
||||||
image: mysql:8.0
|
image: mysql:8.4
|
||||||
container_name: mysql
|
container_name: mysql
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
@@ -9,22 +8,27 @@ services:
|
|||||||
MYSQL_ROOT_PASSWORD: password
|
MYSQL_ROOT_PASSWORD: password
|
||||||
MYSQL_PASSWORD: password
|
MYSQL_PASSWORD: password
|
||||||
MYSQL_USER: php
|
MYSQL_USER: php
|
||||||
ports:
|
healthcheck:
|
||||||
- 3306:3306
|
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-ppassword"]
|
||||||
|
interval: 5s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 30
|
||||||
nginx-php-fpm:
|
nginx-php-fpm:
|
||||||
image: jkaninda/nginx-php-fpm:latest
|
image: ${IMAGE:-jkaninda/nginx-php-fpm:latest}
|
||||||
container_name: nginx-php-fpm
|
container_name: nginx-php-fpm
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
depends_on:
|
depends_on:
|
||||||
- mysql
|
mysql:
|
||||||
|
condition: service_healthy
|
||||||
environment:
|
environment:
|
||||||
|
DB_CONNECTION: mysql
|
||||||
DB_HOST: mysql
|
DB_HOST: mysql
|
||||||
DB_PORT: 3306
|
DB_PORT: 3306
|
||||||
DB_DATABASE: php
|
DB_DATABASE: php
|
||||||
DB_USERNAME: php
|
DB_USERNAME: php
|
||||||
DB_PASSWORD: password
|
DB_PASSWORD: password
|
||||||
|
CLIENT_MAX_BODY_SIZE: 20M
|
||||||
volumes:
|
volumes:
|
||||||
#Project root
|
|
||||||
- ./laravel:/var/www/html
|
- ./laravel:/var/www/html
|
||||||
ports:
|
ports:
|
||||||
- 80:80
|
- "${HTTP_PORT:-80}:80"
|
||||||
Executable
+69
@@ -0,0 +1,69 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Integration test: create a Laravel project with the image, serve it through
|
||||||
|
# the bundled Nginx, run migrations and check that Nginx, PHP-FPM, the queue
|
||||||
|
# worker and the scheduler are running.
|
||||||
|
# Usage: IMAGE=jkaninda/nginx-php-fpm:8.5 [HTTP_PORT=8080] ./tests/integration.sh
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
IMAGE="${IMAGE:-jkaninda/nginx-php-fpm:latest}"
|
||||||
|
HTTP_PORT="${HTTP_PORT:-80}"
|
||||||
|
export IMAGE HTTP_PORT
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
docker compose logs nginx-php-fpm || true
|
||||||
|
docker compose down -v --remove-orphans || true
|
||||||
|
}
|
||||||
|
trap cleanup EXIT
|
||||||
|
|
||||||
|
echo "==> Checking PHP extensions"
|
||||||
|
docker run --rm "$IMAGE" php -m > modules.txt
|
||||||
|
for ext in bcmath exif gd intl mbstring memcached pcntl pdo_mysql pdo_pgsql rdkafka redis zip "Zend OPcache"; do
|
||||||
|
grep -qx "$ext" modules.txt || { echo "Missing extension: $ext"; exit 1; }
|
||||||
|
done
|
||||||
|
if docker run --rm "$IMAGE" php -m 2>&1 | grep -iE 'warning|unable to load'; then
|
||||||
|
echo "PHP startup warnings detected"; exit 1
|
||||||
|
fi
|
||||||
|
rm -f modules.txt
|
||||||
|
docker run --rm "$IMAGE" sh -c 'php -v && composer -V && node -v && npm -v && nginx -t'
|
||||||
|
|
||||||
|
echo "==> Creating Laravel project"
|
||||||
|
rm -rf laravel
|
||||||
|
docker run --rm -v "$PWD:/app" -w /app "$IMAGE" \
|
||||||
|
composer create-project --prefer-dist --no-interaction --no-progress laravel/laravel laravel
|
||||||
|
docker run --rm -v "$PWD/laravel:/var/www/html" "$IMAGE" \
|
||||||
|
chown -R www-data:www-data storage bootstrap/cache database
|
||||||
|
|
||||||
|
echo "==> Starting stack"
|
||||||
|
docker compose up -d
|
||||||
|
|
||||||
|
echo "==> Waiting for the container to be healthy"
|
||||||
|
i=0
|
||||||
|
until [ "$(docker inspect -f '{{.State.Health.Status}}' nginx-php-fpm)" = "healthy" ]; do
|
||||||
|
i=$((i + 1)); [ "$i" -gt 60 ] && { echo "Container not healthy"; exit 1; }
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "==> Checking generated Nginx config"
|
||||||
|
docker exec nginx-php-fpm grep -q "root /var/www/html/public;" /etc/nginx/conf.d/default.conf
|
||||||
|
docker exec nginx-php-fpm grep -q "client_max_body_size 20M;" /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
|
echo "==> Running migrations"
|
||||||
|
docker exec --user www-data nginx-php-fpm php artisan migrate --force
|
||||||
|
|
||||||
|
echo "==> Checking HTTP response"
|
||||||
|
code=$(curl -s -o /dev/null -w '%{http_code}' "http://localhost:$HTTP_PORT")
|
||||||
|
echo "HTTP $code"
|
||||||
|
[ "$code" = "200" ]
|
||||||
|
|
||||||
|
echo "==> Checking supervisor programs"
|
||||||
|
for program in php-fpm nginx Laravel-worker Laravel-scheduler; do
|
||||||
|
i=0
|
||||||
|
until docker exec nginx-php-fpm supervisorctl status | grep "^$program" | grep -q RUNNING; do
|
||||||
|
i=$((i + 1)); [ "$i" -gt 30 ] && { echo "$program is not running"; docker exec nginx-php-fpm supervisorctl status; exit 1; }
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
done
|
||||||
|
docker exec nginx-php-fpm supervisorctl status
|
||||||
|
|
||||||
|
echo "==> All tests passed"
|
||||||
Reference in new issue
Block a user