Skip to content

Commit

Permalink
Merge pull request #32 from openbridge/master
Browse files Browse the repository at this point in the history
rebase
  • Loading branch information
tspicer authored Jan 15, 2021
2 parents b85ca6b + 37a744e commit c206123
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 16 deletions.
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM alpine:3.11
MAINTAINER Thomas Spicer ([email protected])
ARG ALPINE_VERSION=3.11
FROM alpine:${ALPINE_VERSION}
LABEL maintainer="Thomas Spicer ([email protected])"
ARG ALPINE_VERSION

ENV VAR_PREFIX=/var/run
ENV LOG_PREFIX=/var/log/php-fpm
Expand All @@ -14,7 +16,7 @@ RUN set -x \
linux-headers \
curl \
unzip \
&& echo '@community http://dl-cdn.alpinelinux.org/alpine/v3.11/community' >> /etc/apk/repositories \
&& echo "@community http://dl-cdn.alpinelinux.org/alpine/v${ALPINE_VERSION}/community" >> /etc/apk/repositories \
&& apk add --no-cache --update \
php7@community \
php7-dev@community \
Expand Down
34 changes: 29 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,30 @@ This is a Docker image creates a high performance, optimized container for PHP-F
# Versioning
| Docker Tag | Git Hub Release | PHP Version | Alpine Version |
|-----|-------|-----|--------|
| latest | develop | 7.3.x | 3.11 |
| 7.3 | 7.3 | 7.3.x | 3.11 |
| 7.4 | develop | 7.4.x | 3.13 |
| latest | develop | 7.4.x | 3.13 |

# Build
```
docker build -t openbridge/ob_php-fpm .
```
or pull from Docker Hub:

The current default build uses Alpine version `3.11`. However, you can set the Alpine version by passing build arguments.

For example, if you want to use Alpine version `3.13`, set the `--build-arg` with `ALPINE_VERSION` as follows:

```
docker build -t ob_php-fpm --build-arg ALPINE_VERSION=3.13 .
```

or pull from Docker Hub which uses `ALPINE_VERSION=3.13` :
```
docker pull openbridge/ob_php-fpm
```

If you need a different version, you will need to run the basic build process which only takes a few seconds.

# Run
Here is a simple run command:
```bash
Expand Down Expand Up @@ -63,6 +77,10 @@ PHP_START_SERVERS=16
PHP_MIN_SPARE_SERVERS=8
PHP_MAX_SPARE_SERVERS=16
PHP_MEMORY_LIMIT=256
PHP_POST_MAX_SIZE=50
PHP_UPLOAD_MAX_FILESIZE=50
PHP_MAX_INPUT_VARS=1000
PHP_MAX_EXECUTION_TIME=300
PHP_OPCACHE_ENABLE=1
PHP_OPCACHE_MEMORY_CONSUMPTION=96
PHP_MAX_CHILDREN=16
Expand All @@ -88,6 +106,10 @@ The PHP and cache settings are a function of the available system resources. Thi
if [[ -z $PHP_MAX_SPARE_SERVERS ]]; then PHP_MAX_SPARE_SERVERS="${TOTALCPU}" && echo "${PHP_MAX_SPARE_SERVERS}"; fi
if [[ -z $PHP_MEMORY_LIMIT ]]; then PHP_MEMORY_LIMIT=$(($TOTALMEM / 2)) && echo "${PHP_MEMORY_LIMIT}"; fi
if [[ -z $PHP_MAX_CHILDREN ]]; then PHP_MAX_CHILDREN=$(($TOTALCPU * 2)) && echo "${PHP_MAX_CHILDREN}"; fi
if [[ -z $PHP_POST_MAX_SIZE ]]; then PHP_POST_MAX_SIZE="50"; else PHP_POST_MAX_SIZE="${PHP_POST_MAX_SIZE}" fi
if [[ -z $PHP_UPLOAD_MAX_FILESIZE ]]; then PHP_UPLOAD_MAX_FILESIZE="50"; else PHP_UPLOAD_MAX_FILESIZE="${PHP_UPLOAD_MAX_FILESIZE}" fi
if [[ -z $PHP_MAX_INPUT_VARS ]]; then PHP_MAX_INPUT_VARS="1000"; else PHP_MAX_INPUT_VARS="${PHP_MAX_INPUT_VARS}" fi
if [[ -z $PHP_MAX_EXECUTION_TIME ]]; then PHP_MAX_EXECUTION_TIME="300"; else PHP_MAX_EXECUTION_TIME="${PHP_MAX_EXECUTION_TIME}" fi

# Opcache settings
if [[ -z $PHP_OPCACHE_ENABLE ]]; then PHP_OPCACHE_ENABLE=1 && echo "${PHP_OPCACHE_ENABLE}"; fi
Expand Down Expand Up @@ -144,7 +166,7 @@ The following represents the structure of the PHP configs used in this image:
} | tee /etc/php7/php-fpm.d/zz-docker.conf

{
echo 'max_executionn_time=300'
echo 'max_execution_time={{PHP_MAX_EXECUTION_TIME}}'
echo 'memory_limit={{PHP_MEMORY_LIMIT}}M'
echo 'error_reporting=1'
echo 'display_errors=0'
Expand All @@ -155,9 +177,11 @@ The following represents the structure of the PHP configs used in this image:
echo 'date.timezone=UTC'
echo 'short_open_tag=Off'
echo 'session.auto_start=Off'
echo 'upload_max_filesize=50M'
echo 'post_max_size=50M'
echo 'upload_max_filesize={{PHP_UPLOAD_MAX_FILESIZE}}M'
echo 'post_max_size={{PHP_POST_MAX_SIZE}}M'
echo 'file_uploads=On'
echo 'file_uploads=On'
echo 'max_input_vars={{PHP_MAX_INPUT_VARS}}'

echo
echo 'opcache.enable={{PHP_OPCACHE_ENABLE}}'
Expand Down
18 changes: 14 additions & 4 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ function php-fpm() {
if [[ -z $PHP_MAX_SPARE_SERVERS ]]; then PHP_MAX_SPARE_SERVERS="${TOTALCPU}" && echo "${PHP_MAX_SPARE_SERVERS}"; fi
if [[ -z $PHP_MEMORY_LIMIT ]]; then PHP_MEMORY_LIMIT=$(($TOTALMEM / 2)) && echo "${PHP_MEMORY_LIMIT}"; fi
if [[ -z $PHP_MAX_CHILDREN ]]; then PHP_MAX_CHILDREN=$(($TOTALCPU * 2)) && echo "${PHP_MAX_CHILDREN}"; fi

if [[ -z $PHP_POST_MAX_SIZE ]]; then PHP_POST_MAX_SIZE="50"; else PHP_POST_MAX_SIZE="${PHP_POST_MAX_SIZE}"; fi
if [[ -z $PHP_UPLOAD_MAX_FILESIZE ]]; then PHP_UPLOAD_MAX_FILESIZE="50"; else PHP_UPLOAD_MAX_FILESIZE="${PHP_UPLOAD_MAX_FILESIZE}"; fi
if [[ -z $PHP_MAX_INPUT_VARS ]]; then PHP_MAX_INPUT_VARS="1000"; else PHP_MAX_INPUT_VARS="${PHP_MAX_INPUT_VARS}"; fi
if [[ -z $PHP_MAX_EXECUTION_TIME ]]; then PHP_MAX_EXECUTION_TIME="300"; else PHP_MAX_EXECUTION_TIME="${PHP_MAX_EXECUTION_TIME}"; fi

# Opcache settings
if [[ -z $PHP_OPCACHE_ENABLE ]]; then PHP_OPCACHE_ENABLE=1 && echo "${PHP_OPCACHE_ENABLE}"; fi
if [[ -z $PHP_OPCACHE_MEMORY_CONSUMPTION ]]; then PHP_OPCACHE_MEMORY_CONSUMPTION=$(($TOTALMEM / 6)) && echo "${PHP_OPCACHE_MEMORY_CONSUMPTION}"; fi
Expand Down Expand Up @@ -68,7 +72,7 @@ function php-fpm() {
} | tee /etc/php7/php-fpm.d/zz-docker.conf

{
echo 'max_execution_time=300'
echo 'max_execution_time={{PHP_MAX_EXECUTION_TIME}}'
echo 'memory_limit={{PHP_MEMORY_LIMIT}}M'
echo 'error_reporting=1'
echo 'display_errors=0'
Expand All @@ -79,9 +83,11 @@ function php-fpm() {
echo 'date.timezone=UTC'
echo 'short_open_tag=Off'
echo 'session.auto_start=Off'
echo 'upload_max_filesize=50M'
echo 'post_max_size=50M'
echo 'upload_max_filesize={{PHP_UPLOAD_MAX_FILESIZE}}M'
echo 'post_max_size={{PHP_POST_MAX_SIZE}}M'
echo 'file_uploads=On'
echo 'file_uploads=On'
echo 'max_input_vars={{PHP_MAX_INPUT_VARS}}'

echo
echo 'opcache.enable={{PHP_OPCACHE_ENABLE}}'
Expand Down Expand Up @@ -116,6 +122,10 @@ function php-fpm() {
find /etc/php7 -maxdepth 3 -type f -exec sed -i -e 's|{{PHP_OPCACHE_MEMORY_CONSUMPTION}}|'"${PHP_OPCACHE_MEMORY_CONSUMPTION}"'|g' {} \;
find /etc/php7 -maxdepth 3 -type f -exec sed -i -e 's|{{PHP_MAX_CHILDREN}}|'"${PHP_MAX_CHILDREN}"'|g' {} \;
find /etc/php7 -maxdepth 3 -type f -exec sed -i -e 's|{{LOG_PREFIX}}|'"${LOG_PREFIX}"'|g' {} \;
find /etc/php7 -maxdepth 3 -type f -exec sed -i -e 's|{{PHP_POST_MAX_SIZE}}|'"${PHP_POST_MAX_SIZE}"'|g' {} \;
find /etc/php7 -maxdepth 3 -type f -exec sed -i -e 's|{{PHP_UPLOAD_MAX_FILESIZE}}|'"${PHP_UPLOAD_MAX_FILESIZE}"'|g' {} \;
find /etc/php7 -maxdepth 3 -type f -exec sed -i -e 's|{{PHP_MAX_INPUT_VARS}}|'"${PHP_MAX_INPUT_VARS}"'|g' {} \;
find /etc/php7 -maxdepth 3 -type f -exec sed -i -e 's|{{PHP_MAX_EXECUTION_TIME}}|'"${PHP_MAX_EXECUTION_TIME}"'|g' {} \;

}

Expand Down
5 changes: 5 additions & 0 deletions env/dev.env
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ PHP_MAX_SPARE_SERVERS=16
PHP_MEMORY_LIMIT=256
PHP_OPCACHE_MEMORY_CONSUMPTION=96
PHP_MAX_CHILDREN=16
PHP_POST_MAX_SIZE=50
PHP_UPLOAD_MAX_FILESIZE=50
PHP_MAX_INPUT_VARS=1000
PHP_MAX_EXECUTION_TIME=300

4 changes: 4 additions & 0 deletions env/prod.env
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ PHP_MAX_SPARE_SERVERS=16
PHP_MEMORY_LIMIT=256
PHP_OPCACHE_MEMORY_CONSUMPTION=96
PHP_MAX_CHILDREN=16
PHP_POST_MAX_SIZE=50
PHP_UPLOAD_MAX_FILESIZE=50
PHP_MAX_INPUT_VARS=1000
PHP_MAX_EXECUTION_TIME=300
4 changes: 4 additions & 0 deletions env/stage.env
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ PHP_MAX_SPARE_SERVERS=16
PHP_MEMORY_LIMIT=256
PHP_OPCACHE_MEMORY_CONSUMPTION=96
PHP_MAX_CHILDREN=16
PHP_POST_MAX_SIZE=100
PHP_UPLOAD_MAX_FILESIZE=100
PHP_MAX_INPUT_VARS=1000
PHP_MAX_EXECUTION_TIME=500
19 changes: 15 additions & 4 deletions shippable.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
# language setting
language: none

env:
- PHP_VERSION=7.3 TAG=7.3
- PHP_VERSION=7.4 TAG=7.4
- PHP_VERSION=7.4 TAG=latest

pre_ci:
- docker build -t $SHIPPABLE_CONTAINER_NAME:latest
- |
if [ "$PHP_VERSION" == "7.4" ]; then
docker build --build-arg ALPINE_VERSION=3.13 -t $SHIPPABLE_CONTAINER_NAME:$TAG
else
docker build -t $SHIPPABLE_CONTAINER_NAME:$TAG
fi
build:
post_ci:
- sudo pip install -U docker-compose awscli
- docker commit $SHIPPABLE_CONTAINER_NAME
post_ci:
- sudo pip install -U docker-compose awscli
- docker commit $SHIPPABLE_CONTAINER_NAME

0 comments on commit c206123

Please sign in to comment.