Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
nbejansen committed Apr 30, 2024
0 parents commit f03ab4f
Show file tree
Hide file tree
Showing 35 changed files with 1,265 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
on:
workflow_call:
inputs:
target:
required: true
type: string
version:
required: true
type: string

jobs:
build-and-test-php:
runs-on: ubuntu-22.04

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Generate Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/sitepilot/${{ inputs.target }}
flavor: |
latest=false
tags: |
type=ref,event=pr,prefix=${{ inputs.version }}-
type=ref,event=branch,prefix=${{ inputs.version }}-
type=raw,enable={{is_default_branch}},value=${{ inputs.version }}
- name: Build and publish image
uses: docker/build-push-action@v5
with:
context: ./src
target: ${{ inputs.target }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64, linux/arm64
cache-from: type=gha,scope=${{ inputs.target }}-${{ inputs.version }}
cache-to: type=gha,mode=max,scope=${{ inputs.target }}-${{ inputs.version }}
provenance: false
build-args: |
PHP_VERSION=${{ inputs.version }}
21 changes: 21 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: php

on:
push:
branches:
- '1.x'
paths:
- "./src/php"
workflow_dispatch:

jobs:
php:
uses: ./.github/workflows/build-image.yml
strategy:
matrix:
php: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]
fail-fast: true
with:
target: php
version: ${{ matrix.php }}
secrets: inherit
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
.env
flight.yml
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Sitepilot

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
118 changes: 118 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# Docker PHP

Docker PHP is a collection of optimized and extensible container images for running PHP applications in production.

All images are based on our [Docker Runtime](https://github.com/sitepilot/docker-runtime) image, an optimized and
extensible Ubuntu container image.

## Usage

This repository creates several variations of Docker images, enabling you to select precisely what you require. Just
utilize this image naming pattern in any of your projects:

```bash
ghcr.io/sitepilot/php-{{variation-name}}:{{php-version}}
```

For example, if you wish to run **PHP 8.3** with **FPM** & **NGINX**, use the following image name:

```bash
ghcr.io/sitepilot/php-nginx:8.3
```

### Customization

To use this image as a base image and avoid potential breaking changes in your container builds, use the following
image naming pattern in your `Dockerfile`:

```Dockerfile
FROM ghcr.io/sitepilot/php-{{variation-name}}:{{php-version}}-{{release-version}}
```

The images are tagged according to Semantic Versioning (SemVer). Available releases can be found on the [releases page](https://github.com/sitepilot/docker-php/releases). For example, if you wish to customize the **PHP 8.3** with **FPM** & **NGINX** image:

```Dockerfile
# Guaranteed backward compatibility, new features and bug fixes.
FROM ghcr.io/sitepilot/php-nginx:8.3-1
```

```Dockerfile
# Guaranteed backward compatibility and bug fixes.
FROM ghcr.io/sitepilot/php-nginx:8.3-1.0
```

```Dockerfile
# Guaranteed backward compatibility and no updates.
FROM ghcr.io/sitepilot/php-nginx:8.3-1.0.0
```

## Variations

The following Docker image variations are available:

| Image | Description |
|-------------------------------|----------------------------------------|
| `ghcr.io/sitepilot/php-cli` | PHP command line interface. |
| `ghcr.io/sitepilot/php-fpm` | PHP with PHP-FPM. |
| `ghcr.io/sitepilot/php-nginx` | PHP-FPM with Nginx web server. |
| `ghcr.io/sitepilot/php-ols` | PHP-FPM with OpenLitespeed web server. |

## Versions

The following PHP versions are available:

* PHP 7.4
* PHP 8.0
* PHP 8.1
* PHP 8.2
* PHP 8.3

You can find a list of installed PHP extensions for each PHP version [here](./src/packages).

## Environment

The following environment variables are available to modify the configuration of an image:

| Name | Value | php-nginx | php-ols | php-fpm | php-cli |
|-----------------------------|-----------|-----------|---------|---------|---------|
| `PHP_DATE_TIMEZONE` | `UTC` |||||
| `PHP_MEMORY_LIMIT` | `256M` |||||
| `PHP_MAX_EXECUTION_TIME` | `300` |||||
| `PHP_MAX_INPUT_VARS` | `10000` |||||
| `PHP_FPM_CONTROL` | `dynamic` |||| |
| `PHP_FPM_MAX_CHILDREN` | `20` |||| |
| `PHP_FPM_START_SERVERS` | `2` |||| |
| `PHP_FPM_MIN_SPARE_SERVERS` | `1` |||| |
| `PHP_FPM_MAX_SPARE_SERVERS` | `3` |||| |
| `PHP_POST_MAX_SIZE` | `100M` ||| | |
| `PHP_UPLOAD_MAX_FILESIZE` | `100M` ||| | |

## Variation Specific Docs

### PHP-NGINX

#### Environment

| Name | Value |
|------------------------------|------------------|
| `NGINX_PUBLIC_DIR` | - |
| `NGINX_FASTCGI_PASS` | `127.0.0.1:9000` |

#### Add a vhost / site

Custom vhosts are loaded from the `/etc/nginx/sites-enabled` folder. Mount a file with a `.conf` extension to this
folder to add a custom vhost.

#### Add location directive

Custom location directives are loaded from the `/etc/nginx/location.d` folder. Mount a file with a `.conf` extension to
this folder to add a custom location directive.

### PHP-OLS

#### Environment

| Name | Value |
|--------------------|------------------|
| `OLS_PUBLIC_DIR` | - |
| `OLS_FASTCGI_PASS` | `127.0.0.1:9000` |
56 changes: 56 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
services:
runtime:
image: ghcr.io/sitepilot/runtime:22.04
profiles:
- donotstart
environment:
RUNTIME_VERBOSITY: 2
build:
context: ./src
target: runtime

php:
image: ghcr.io/sitepilot/php:8.3
profiles:
- donotstart
environment:
RUNTIME_VERBOSITY: 2
build:
context: ./src
target: php

php-fpm:
image: ghcr.io/sitepilot/php-fpm:8.3
profiles:
- donotstart
environment:
RUNTIME_VERBOSITY: 2
build:
context: ./src
target: php-fpm

php-nginx:
image: ghcr.io/sitepilot/php-nginx:8.3
profiles:
- donotstart
ports:
- :80
- :443
environment:
RUNTIME_VERBOSITY: 2
build:
context: ./src
target: php-nginx

php-ols:
image: ghcr.io/sitepilot/php-ols:8.3
profiles:
- donotstart
ports:
- :80
- :443
environment:
RUNTIME_VERBOSITY: 1
build:
context: ./src
target: php-ols
Loading

0 comments on commit f03ab4f

Please sign in to comment.