-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Starting new Docker image from php8 image base
- Loading branch information
0 parents
commit f80fe0b
Showing
29 changed files
with
883 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Deploy images to Docker Hub | ||
on: [push, workflow_dispatch] | ||
|
||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: true | ||
max-parallel: 5 | ||
matrix: { type: [fpm-dev, fpm-prod, nginx-fpm-dev, nginx-fpm-prod, quality] } | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Build and export to Docker | ||
uses: docker/build-push-action@v5 | ||
with: { load: true, context: "${{ matrix.type }}", tags: "scaffoldeducation/php8:${{ matrix.type }}" } | ||
|
||
- name: Test images | ||
run: ./test.build.sh ${{ matrix.type }} && ./test.run.sh ${{ matrix.type }} | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v3 | ||
if: github.ref == 'refs/heads/main' && github.repository == 'scaffoldeducation/php8' | ||
with: { username: "${{ secrets.DOCKERHUB_USERNAME }}", password: "${{ secrets.DOCKERHUB_PASSWORD }}" } | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
if: github.ref == 'refs/heads/main' && github.repository == 'scaffoldeducation/php8' | ||
with: { push: true, context: "${{ matrix.type }}", tags: "scaffoldeducation/php8:${{ matrix.type }}" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Update Docker Hub image description | ||
on: | ||
push: | ||
branches: [main] | ||
paths: [README.md, .github/workflows/dockerhub-description.yml] | ||
|
||
jobs: | ||
docker-description: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Sync Docker Hub Description | ||
uses: peter-evans/dockerhub-description@v3.4.2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
repository: scaffoldeducation/php8 | ||
short-description: ${{ github.event.repository.description }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.env | ||
.secrets | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"files.associations": { | ||
"entrypoint*": "shellscript", | ||
"supervisor.conf": "ini", | ||
"www.conf": "nginx", | ||
"zz-docker.conf": "ini" | ||
}, | ||
"material-icon-theme.files.associations": { | ||
"www.conf": "nginx" | ||
}, | ||
"material-icon-theme.folders.associations": { | ||
"fpm-dev": "php", | ||
"fpm-prod": "php", | ||
"nginx-fpm-dev": "global", | ||
"nginx-fpm-prod": "global", | ||
"quality": "error" | ||
}, | ||
"filewatcher.autoClearConsole": true, | ||
"filewatcher.shell": "/usr/bin/zsh", | ||
"workbench.colorCustomizations": { | ||
"sideBar.background": "#35343f" | ||
}, | ||
"filewatcher.commands": [ | ||
{ | ||
"match": "./fpm-dev/*", | ||
"vscodeTask": ["workbench.action.tasks.runTask", "fpm-dev"], | ||
"event": "onFileChange" | ||
}, | ||
{ | ||
"match": "./fpm-prod/*", | ||
"vscodeTask": ["workbench.action.tasks.runTask", "fpm-prod"], | ||
"event": "onFileChange" | ||
}, | ||
{ | ||
"match": "./nginx-fpm-dev/*", | ||
"vscodeTask": ["workbench.action.tasks.runTask", "nginx-fpm-dev"], | ||
"event": "onFileChange" | ||
}, | ||
{ | ||
"match": "./nginx-fpm-prod/*", | ||
"vscodeTask": ["workbench.action.tasks.runTask", "nginx-fpm-prod"], | ||
"event": "onFileChange" | ||
}, | ||
{ | ||
"match": "./quality/*", | ||
"vscodeTask": ["workbench.action.tasks.runTask", "quality"], | ||
"event": "onFileChange" | ||
}, | ||
{ | ||
"match": ".github/workflows/*", | ||
"vscodeTask": ["workbench.action.tasks.runTask", "act"], | ||
"event": "onFileChange" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "fpm-dev", | ||
"type": "shell", | ||
"command": "./test.build.sh fpm-dev && ./test.run.sh fpm-dev", | ||
"presentation": { "clear": true } | ||
}, | ||
{ | ||
"label": "fpm-prod", | ||
"type": "shell", | ||
"command": "./test.build.sh fpm-prod && ./test.run.sh fpm-prod", | ||
"presentation": { "clear": true } | ||
}, | ||
{ | ||
"label": "nginx-fpm-dev", | ||
"type": "shell", | ||
"command": "./test.build.sh nginx-fpm-dev && ./test.run.sh nginx-fpm-dev", | ||
"presentation": { "clear": true } | ||
}, | ||
{ | ||
"label": "nginx-fpm-prod", | ||
"type": "shell", | ||
"command": "./test.build.sh nginx-fpm-prod && ./test.run.sh nginx-fpm-prod", | ||
"presentation": { "clear": true } | ||
}, | ||
{ | ||
"label": "quality", | ||
"type": "shell", | ||
"command": "./test.build.sh quality && ./test.run.sh quality", | ||
"presentation": { "clear": true } | ||
}, | ||
{ | ||
"label": "act", | ||
"type": "shell", | ||
"linux": { "command": "act" }, | ||
"presentation": { "clear": true } | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
<p align="center"> | ||
<img src="https://github.com/scaffoldeducation/php8/raw/main/.github/docker-php.png" width="198" /> | ||
</p> | ||
|
||
<h1 align="center">Scaffold PHP 8 Docker Image</h1> | ||
|
||
<br> | ||
|
||
> Based on [**kooldev/php**](https://github.com/kool-dev/docker-php) docker image | ||
> _from [Firework Web](https://github.com/fireworkweb)_ | ||
<br> | ||
|
||
A Docker image created on top of [**php-fpm** official image](https://hub.docker.com/_/php) running on Alpine 3.16. It is a multi-environment/multi-purpose image that has several PHP extensions installed, such as MongoDB and Xdebug for example. | ||
|
||
The final size of the images is considerably small if you take into account the content of each image: | ||
|
||
``` | ||
scaffoldeducation/php8:fpm-dev 277MB | ||
scaffoldeducation/php8:fpm-prod 277MB | ||
scaffoldeducation/php8:nginx-fpm-dev 321MB | ||
scaffoldeducation/php8:nginx-fpm-prod 321MB | ||
scaffoldeducation/php8:quality 341MB | ||
``` | ||
|
||
<br> | ||
|
||
**Summary** | ||
|
||
<!-- TOC --> | ||
|
||
- [Usage](#usage) | ||
- [Tags](#tags) | ||
- [Contents](#contents) | ||
- [Core](#core) | ||
- [Tools](#tools) | ||
- [Libs](#libs) | ||
- [PHP Extensions](#php-extensions) | ||
- [Nginx best practices](#nginx-best-practices) | ||
- [Quality Tools](#quality-tools) | ||
- [Check versions](#check-versions) | ||
- [TODO](#todo) | ||
|
||
<!-- /TOC --> | ||
|
||
<br> | ||
|
||
## Usage | ||
|
||
```Dockerfile | ||
FROM scaffoldeducation/php8:fpm-dev | ||
FROM scaffoldeducation/php8:fpm-prod | ||
FROM scaffoldeducation/php8:nginx-fpm-dev | ||
FROM scaffoldeducation/php8:nginx-fpm-prod | ||
FROM scaffoldeducation/php8:quality | ||
``` | ||
|
||
<br> | ||
|
||
## Tags | ||
|
||
<br> | ||
|
||
| Tag | Description | | ||
|----------------------|----------------------------------------------------------------------------------------------------| | ||
| **`fpm-dev`** | it has a lot of extensions installed, but not `opcache` | | ||
| **`fpm-prod`** | it has everything from `fpm-dev` except `xdebug` and it includes `opcache` | | ||
| **`nginx-fpm-dev`** | based on `fpm-dev`, it has nginx installed with SSL support | | ||
| **`nginx-fpm-prod`** | same above but based on `fpm-prod` | | ||
| **`quality`** | it descends from `fpm-dev` too but its main purpose is to run [code quality tools](#quality-tools) | | ||
|
||
<br> | ||
|
||
## Contents | ||
|
||
<br> | ||
|
||
### Core | ||
|
||
- Alpine Linux `3.16` | ||
- php-fpm `8.0.27` | ||
- nginx `1.22.1` | ||
|
||
<br> | ||
|
||
### Tools | ||
|
||
- dockerize `0.7.0` | ||
- supervisor `0.6.3` | ||
- composer `2` | ||
|
||
<br> | ||
|
||
### Libs | ||
|
||
- **dependencies**: `bash` `freetype` `ghostscript` `gifsicle` `icu` `imagemagick` `jpegoptim` `less` `libjpeg-turbo` `libldap` `libpng` `libpq` `libzip-dev` `openssh-client` `optipng` `pngquant` `procps` `shadow` `su-exec` | ||
|
||
- **build-dependencies**: `freetype-dev` `icu-dev` `imagemagick-dev` `libedit-dev` `libjpeg-turbo-dev` `libpng-dev` `libxml2-dev` `linux-headers` `oniguruma-dev` `openldap-dev` `postgresql-dev` | ||
|
||
<br> | ||
|
||
### PHP Extensions | ||
|
||
- **`mysqli`** **`mongodb`** **`redis`** **`xdebug`** `bcmath` `calendar` `exif` `gd` `imagick` `intl` `ldap` `mbstring` `opcache` `pcntl` `pdo` `pdo_mysql` `pdo_pgsql` `soap` `sockets` `xml` `zip` | ||
|
||
<br> | ||
|
||
### Nginx best practices | ||
|
||
- **`h5bp`** `3.3.0` for nginx performance and security | ||
|
||
<br> | ||
|
||
### Quality Tools | ||
|
||
- **`phan`** `5.4.2` | ||
- **`phpcpd`** `6.0.3` | ||
- **`phpcs`** `3.7.2` | ||
- **`php-cs-fixer`** `3.40.0` | ||
- **`phpmd`** `2.14.1` | ||
- **`phpstan`** `1.10.45` | ||
- **`phpunit`** `9.6.13` | ||
|
||
<br> | ||
|
||
## Check versions | ||
|
||
```sh | ||
php --ri imagick # 3.7.0 | ||
php --ri mongodb # 1.17.0 | ||
php --ri pcov # 1.0.11 | ||
php --ri redis # 6.0.2 | ||
php --ri xdebug # 3.2.2 | ||
``` | ||
|
||
<br> | ||
|
||
## TODO | ||
|
||
- [ ] Allow customize versions of PECL extensions | ||
- [ ] Write tests for SSL support in nginx | ||
|
||
<br> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
FROM php:8.0.27-fpm-alpine3.16 | ||
|
||
ARG PHP_DATE_TIMEZONE=UTC \ | ||
PHP_FPM_MAX_CHILDREN=10 \ | ||
PHP_FPM_REQUEST_TERMINATE_TIMEOUT=60 \ | ||
PHP_MAX_EXECUTION_TIME=30 \ | ||
PHP_MAX_INPUT_VARS=1000 \ | ||
PHP_MEMORY_LIMIT=256M \ | ||
PHP_POST_MAX_SIZE=25M \ | ||
PHP_UPLOAD_MAX_FILESIZE=25M | ||
|
||
ENV ASUSER=${ASUSER:-1000} \ | ||
COMPOSER_ALLOW_SUPERUSER=1 \ | ||
COMPOSER_MEMORY_LIMIT=${COMPOSER_MEMORY_LIMIT:--1} \ | ||
ENABLE_XDEBUG=${ENABLE_XDEBUG:-true} \ | ||
XDEBUG_MODE=${XDEBUG_MODE:-debug} \ | ||
XDEBUG_CONFIG=${XDEBUG_CONFIG:-"client_host=192.168.15.20"} \ | ||
PHP_DATE_TIMEZONE=${PHP_DATE_TIMEZONE} \ | ||
PHP_FPM_LISTEN=9000 \ | ||
PHP_FPM_MAX_CHILDREN=${PHP_FPM_MAX_CHILDREN} \ | ||
PHP_FPM_REQUEST_TERMINATE_TIMEOUT=${PHP_FPM_REQUEST_TERMINATE_TIMEOUT} \ | ||
PHP_MAX_EXECUTION_TIME=${PHP_MAX_EXECUTION_TIME} \ | ||
PHP_MAX_INPUT_VARS=${PHP_MAX_INPUT_VARS} \ | ||
PHP_MEMORY_LIMIT=${PHP_MEMORY_LIMIT} \ | ||
PHP_POST_MAX_SIZE=${PHP_POST_MAX_SIZE} \ | ||
PHP_UPLOAD_MAX_FILESIZE=${PHP_UPLOAD_MAX_FILESIZE} | ||
|
||
WORKDIR /app | ||
RUN set -x \ | ||
&& adduser -D -u ${ASUSER} scaffold \ | ||
&& addgroup scaffold www-data \ | ||
&& apk add --no-cache \ | ||
bash freetype ghostscript gifsicle icu imagemagick jpegoptim less libjpeg-turbo libldap \ | ||
libpng libpq libzip-dev openssh-client optipng pngquant procps shadow su-exec >/dev/null 2>&1 \ | ||
&& apk add --no-cache --virtual .build-deps ${PHPIZE_DEPS} \ | ||
freetype-dev icu-dev imagemagick-dev libedit-dev libjpeg-turbo-dev libpng-dev \ | ||
libxml2-dev linux-headers oniguruma-dev openldap-dev >/dev/null 2>&1 \ | ||
&& docker-php-ext-configure gd --with-freetype --with-jpeg >/dev/null 2>&1 \ | ||
&& export CFLAGS="$PHP_CFLAGS" CPPFLAGS="$PHP_CPPFLAGS" LDFLAGS="$PHP_LDFLAGS" \ | ||
&& docker-php-ext-install -j$(nproc) \ | ||
bcmath calendar exif gd intl ldap mbstring mysqli \ | ||
pcntl pdo pdo_mysql soap sockets xml zip >/dev/null 2>&1 \ | ||
&& pecl install imagick-3.7.0 >/dev/null 2>&1 \ | ||
&& pecl install mongodb-1.17.0 >/dev/null 2>&1 \ | ||
&& pecl install pcov-1.0.11 >/dev/null 2>&1 \ | ||
&& pecl install redis-6.0.2 >/dev/null 2>&1 \ | ||
&& pecl install xdebug-3.2.2 >/dev/null 2>&1 \ | ||
&& docker-php-ext-enable imagick mongodb pcov redis >/dev/null 2>&1 \ | ||
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \ | ||
&& curl -L https://github.com/jwilder/dockerize/releases/download/v0.7.0/dockerize-alpine-linux-amd64-v0.7.0.tar.gz | tar xz \ | ||
&& mv dockerize /usr/local/bin/dockerize \ | ||
&& mv /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini \ | ||
&& apk del .build-deps \ | ||
&& rm -rf /var/cache/apk/* /tmp/* | ||
|
||
EXPOSE ${PHP_FPM_LISTEN} | ||
COPY --chmod=755 . /scaffold/ | ||
ENTRYPOINT ["/scaffold/entrypoint"] | ||
CMD ["php-fpm"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
if [ "$ENABLE_XDEBUG" == 'true' ]; then | ||
docker-php-ext-enable xdebug >>/dev/null 2>&1 | ||
[ $? != '0' ] && echo '[ERROR] An error happened enabling xdebug' && exit 1 | ||
fi | ||
|
||
dockerize \ | ||
-template /scaffold/scaffold.ini:/usr/local/etc/php/conf.d/scaffold.ini \ | ||
-template /scaffold/zz-docker.conf:/usr/local/etc/php-fpm.d/zz-docker.conf | ||
|
||
if [[ "$1" =~ 'sh' ]] || [[ "$1" =~ 'bash' ]] || [[ "$1" =~ 'php-fpm' ]] | ||
then exec su-exec root "${@}" | ||
else exec su-exec ${ASUSER} "${@}" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[PHP] | ||
date.timezone = {{ .Env.PHP_DATE_TIMEZONE }} | ||
max_execution_time = {{ .Env.PHP_MAX_EXECUTION_TIME }} | ||
max_input_vars = {{ .Env.PHP_MAX_INPUT_VARS }} | ||
memory_limit = {{ .Env.PHP_MEMORY_LIMIT }} | ||
post_max_size = {{ .Env.PHP_POST_MAX_SIZE }} | ||
upload_max_filesize = {{ .Env.PHP_UPLOAD_MAX_FILESIZE }} |
Oops, something went wrong.