stacksmith merger (#36)

* removed stray index.php

* switch to harpoon installer

* removed unused `installer.run.sha256`

* bump version to 7.0.3-0

* added sha256 hash for package verification

* organize dockerfile for stacksmith (#1)

* use php harpoon module
* added hack to move `/opt/bitnami/php/conf/` to `/bitnami/php-fpm/conf`
* tests: updated

* update to php-7.0.5-1 (#2)

* upgrade to `gcr.io/stacksmith-images/ubuntu:14.04-r06`

* upgrade to php-7.0.5-1

* set workdir to `/app`

* define /bitnami/php VOLUME

* updated readme

* readme: fixes

* clean ups

* upgrade to `php-7.0.6-0` harpoon module

* define `BITNAMI_IMAGE_VERSION` env variable

* ignore `pkg-cache/` in git

* ignore `.git/` and `tests/` directories in docker builds

* upgrade to `gcr.io/stacksmith-images/ubuntu:14.04-r07` baseimage

* ignore `pkg-cache/` in git

* updated changelog
This commit is contained in:
Sameer Naik 2016-05-19 04:10:48 +05:30 committed by Adnan Abdulhussein
parent 82dba3346a
commit f182503a88
14 changed files with 117 additions and 236 deletions

View File

@ -0,0 +1,2 @@
.git/
tests/

1
bitnami/php-fpm/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
pkg-cache/

View File

@ -1,22 +1,19 @@
FROM bitnami/base-ubuntu:14.04-onbuild
FROM gcr.io/stacksmith-images/ubuntu:14.04-r07
MAINTAINER Bitnami <containers@bitnami.com>
ENV BITNAMI_APP_NAME=php-fpm \
BITNAMI_APP_USER=bitnami \
BITNAMI_APP_DAEMON=php-fpm \
BITNAMI_APP_VERSION=5.6.18-1 \
BITNAMI_APP_DIR=$BITNAMI_PREFIX/php
ENV BITNAMI_IMAGE_VERSION=7.0.6-r0 \
BITNAMI_APP_NAME=php \
BITNAMI_APP_USER=daemon
ENV BITNAMI_APP_VOL_PREFIX=/bitnami/$BITNAMI_APP_NAME \
PATH=$BITNAMI_APP_DIR/sbin:$BITNAMI_APP_DIR/bin:$BITNAMI_PREFIX/common/bin:$PATH
RUN $BITNAMI_PREFIX/install.sh\
--php_fpm_allow_all_remote_connections 1 --php_fpm_connection_mode port
RUN bitnami-pkg unpack php-7.0.6-0 --checksum 8ca32e21642fbe2fd23cdf7459d6cb4b65bb1b89b0e230333c8da553135d79a6
ENV PATH=/opt/bitnami/$BITNAMI_APP_NAME/sbin:/opt/bitnami/$BITNAMI_APP_NAME/bin:/opt/bitnami/common/bin:$PATH
COPY rootfs/ /
ENTRYPOINT ["/app-entrypoint.sh"]
CMD ["harpoon", "start", "--foreground", "php"]
VOLUME ["/bitnami/$BITNAMI_APP_NAME"]
EXPOSE 9000
VOLUME ["$BITNAMI_APP_VOL_PREFIX/logs", "$BITNAMI_APP_VOL_PREFIX/conf"]
WORKDIR /app
ENTRYPOINT ["/entrypoint.sh"]
EXPOSE 9000

View File

@ -1,16 +1,16 @@
[![Build
Status](http://bitnami-container-builds.bitnamiapp.com/jenkins/buildStatus/icon?job=docker-php-fpm)](http://bitnami-container-builds.bitnamiapp.com/jenkins/job/docker-php-fpm/)
# What is PHP-FPM?
> PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some
> additional features useful for sites of any size, especially busier sites.
> PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features useful for sites of any size, especially busier sites.
[php-fpm.org](http://php-fpm.org/)
# TLDR
```bash
docker run -it --name phpfpm bitnami/php-fpm
docker run -it --name phpfpm -v /path/to/app:/app bitnami/php-fpm
```
## Docker Compose
@ -19,21 +19,18 @@ docker run -it --name phpfpm bitnami/php-fpm
phpfpm:
image: bitnami/php-fpm
volumes:
- /path/to/php/app:/app
- /path/to/app:/app
```
# Get this image
The recommended way to get the Bitnami PHP-FPM Docker Image is to pull the prebuilt image from the
[Docker Hub Registry](https://hub.docker.com/r/bitnami/php-fpm).
The recommended way to get the Bitnami PHP-FPM Docker Image is to pull the prebuilt image from the [Docker Hub Registry](https://hub.docker.com/r/bitnami/php-fpm).
```bash
docker pull bitnami/php-fpm:latest
```
To use a specific version, you can pull a versioned tag. You can view the
[list of available versions](https://hub.docker.com/r/bitnami/php-fpm/tags/)
in the Docker Hub Registry.
To use a specific version, you can pull a versioned tag. You can view the [list of available versions](https://hub.docker.com/r/bitnami/php-fpm/tags/) in the Docker Hub Registry.
```bash
docker pull bitnami/php-fpm:[TAG]
@ -42,36 +39,26 @@ docker pull bitnami/php-fpm:[TAG]
If you wish, you can also build the image yourself.
```bash
git clone https://github.com/bitnami/bitnami-docker-php-fpm.git
cd bitnami-docker-php-fpm
docker build -t bitnami/php-fpm .
docker build -t bitnami/php-fpm https://github.com/bitnami/bitnami-docker-php-fpm.git
```
# Linking
This image is designed to be used with a web server to serve your PHP app, you can use the linking
system provided by Docker to do this.
This image is designed to be used with a web server to serve your PHP app, you can use the linking system provided by Docker to do this.
## Serving your PHP app through an nginx frontend
We will use PHP-FPM with nginx to serve our PHP app. Doing so will allow us to setup more complex
configuration, serve static assets using nginx, load balance to different PHP-FPM instances, etc.
We will use PHP-FPM with nginx to serve our PHP app. Doing so will allow us to setup more complex configuration, serve static assets using nginx, load balance to different PHP-FPM instances, etc.
### Step 1: Create a virtual host
Let's create an nginx virtual host to reverse proxy to our PHP-FPM container.
[The Bitnami nginx Docker Image](https://github.com/bitnami/bitnami-docker-nginx) ships with some
example virtual hosts for connecting to Bitnami runtime images. We will make use of the PHP-FPM
example:
```
server {
listen 0.0.0.0:80;
server_name yourapp.com;
access_log /bitnami/nginx/logs/yourapp_access.log;
error_log /bitnami/nginx/logs/yourapp_error.log;
root /app;
location / {
@ -88,19 +75,16 @@ server {
```
Notice we've substituted the link alias name `yourapp`, we will use the same name when creating the
link.
Notice we've substituted the link alias name `yourapp`, we will use the same name when creating the link.
Copy the virtual host above, saving the file somewhere on your host. We will mount it as a volume
in our nginx container.
Copy the virtual host above, saving the file somewhere on your host. We will mount it as a volume in our nginx container.
### Step 2: Run the PHP-FPM image with a specific name
Docker's linking system uses container ids or names to reference containers. We can explicitly
specify a name for our PHP-FPM server to make it easier to connect to other containers.
Docker's linking system uses container ids or names to reference containers. We can explicitly specify a name for our PHP-FPM server to make it easier to connect to other containers.
```
docker run -it --name phpfpm -v /path/to/php/app:/app bitnami/php-fpm
docker run -it --name phpfpm -v /path/to/app:/app bitnami/php-fpm
```
or using Docker Compose:
@ -109,16 +93,12 @@ or using Docker Compose:
phpfpm:
image: bitnami/php-fpm
volumes:
- /path/to/php/app:/app
- /path/to/app:/app
```
### Step 3: Run the nginx image and link it to the PHP-FPM server
Now that we have our PHP-FPM server running, we can create another container that links to it by
giving Docker the `--link` option. This option takes the id or name of the container we want to link
it to as well as a hostname to use inside the container, separated by a colon. For example, to have
our PHP-FPM server accessible in another container with `yourapp` as it's hostname we would pass
`--link phpfpm:yourapp` to the Docker run command.
Now that we have our PHP-FPM server running, we can create another container that links to it by giving Docker the `--link` option. This option takes the id or name of the container we want to link it to as well as a hostname to use inside the container, separated by a colon. For example, to have our PHP-FPM server accessible in another container with `yourapp` as it's hostname we would pass `--link phpfpm:yourapp` to the Docker run command.
```bash
docker run -it -v /path/to/vhost.conf:/bitnami/nginx/conf/vhosts/yourapp.conf \
@ -134,18 +114,14 @@ nginx:
links:
- phpfpm:yourapp
volumes:
- /path/to/vhost.conf:/bitnami/nginx/conf/yourapp.conf
- /path/to/vhost.conf:/bitnami/nginx/conf/vhosts/yourapp.conf
```
We started the nginx server, mounting the virtual host we created in
[Step 1](#step-1-create-a-virtual-host), and created a link to the PHP-FPM server with the alias
`yourapp`.
We started the nginx server, mounting the virtual host we created in [Step 1](#step-1-create-a-virtual-host), and created a link to the PHP-FPM server with the alias `yourapp`.
# PHP runtime
Since this image bundles a PHP runtime, you may want to make use of PHP outside of PHP-FPM. By
default, running this image will start a server. To use the PHP runtime instead, we can override the
the default command Docker runs by stating a different command to run after the image name.
Since this image bundles a PHP runtime, you may want to make use of PHP outside of PHP-FPM. By default, running this image will start a server. To use the PHP runtime instead, we can override the the default command Docker runs by stating a different command to run after the image name.
## Entering the REPL
@ -161,26 +137,23 @@ docker run -it --name phpfpm bitnami/php-fpm php -a
# Running your PHP script
The default work directory for the PHP-FPM image is `/app`. You can mount a folder from your host
here that includes your PHP script, and run it normally using the `php` command.
The default work directory for the PHP-FPM image is `/app`. You can mount a folder from your host here that includes your PHP script, and run it normally using the `php` command.
```bash
docker run -it --name php-fpm -v /path/to/php/app:/app bitnami/php-fpm \
docker run -it --name php-fpm -v /path/to/app:/app bitnami/php-fpm \
php script.php
```
# Configuration
This container looks for configuration in `/bitnami/php-fpm/conf`. You can mount a directory there
with your own configuration, or the default configuration will be copied to your directory if it is
empty.
This container looks for configurations in `/bitnami/php/conf`. You can mount a directory at `/bitnami/php` with your own configurations in `conf/`, or the default configuration will be copied at `conf/` if it is empty.
### Step 1: Run the PHP-FPM image
Run the PHP-FPM image, mounting a directory from your host.
```bash
docker run --name phpfpm -v /path/to/phpfpm/conf:/bitnami/php-fpm/conf bitnami/php-fpm
docker run --name phpfpm -v /path/to/php:/bitnami/php bitnami/php-fpm
```
or using Docker Compose:
@ -189,7 +162,7 @@ or using Docker Compose:
phpfpm:
image: bitnami/php-fpm
volumes:
- /path/to/phpfpm/conf:/bitnami/php-fpm/conf
- /path/to/php:/bitnami/php/conf
```
### Step 2: Edit the configuration
@ -197,7 +170,7 @@ phpfpm:
Edit the configuration on your host using your favorite editor.
```bash
vi /path/to/phpfpm/conf/php-fpm.conf
vi /path/to/php/conf/php-fpm.conf
```
### Step 4: Restart PHP-FPM
@ -214,22 +187,11 @@ or using Docker Compose:
docker-compose restart phpfpm
```
**Note!**
You can also reload PHP-FPM by sending the `USR2` signal to the container using the `docker kill` command.
```bash
docker kill -s USR2 phpfpm
```
# Logging
The Bitnami PHP-FPM Docker Image supports two different logging modes: logging to stdout, and
logging to a file.
The Bitnami PHP-FPM Docker Image sends the container logs to the `stdout`. You can configure the containers [logging driver](https://docs.docker.com/engine/reference/run/#logging-drivers-log-driver) using the `--log-driver` option. By defauly the `json-file` driver is used.
## Logging to stdout
The default behavior is to log to stdout, as Docker expects. These will be collected by Docker,
converted to JSON and stored in the host, to be accessible via the `docker logs` command.
To view the logs:
```bash
docker logs phpfpm
@ -241,36 +203,13 @@ or using Docker Compose:
docker-compose logs phpfpm
```
This method of logging has the downside of not being easy to manage. Without an easy way to rotate
logs, they could grow exponentially and take up large amounts of disk space on your host.
## Logging to file
To log to file, run the PHP-FPM image, mounting a directory from your host at
`/bitnami/php-fpm/logs`. This will instruct the container to send logs to a `php-fpm.log` file in the
mounted volume.
```bash
docker run --name phpfpm -v /path/to/phpfpm/logs:/bitnami/php-fpm/logs bitnami/php-fpm
```
or using Docker Compose:
```
phpfpm:
image: bitnami/php-fpm
volumes:
- /path/to/phpfpm/logs:/bitnami/php-fpm/logs
```
To perform operations (e.g. logrotate) on the logs, mount the same directory in a container designed
to operate on log files, such as logstash.
*The `docker logs` command is only available when the `json-file` or `journald` logging driver is in use.*
# Maintenance
## Backing up your container
To backup your configuration and logs, follow these simple steps:
To backup your configurations, follow these simple steps:
### Step 1: Stop the currently running container
@ -286,33 +225,26 @@ docker-compose stop phpfpm
### Step 2: Run the backup command
We need to mount two volumes in a container we will use to create the backup: a directory on your
host to store the backup in, and the volumes from the container we just stopped so we can access the
data.
We need to mount two volumes in a container we will use to create the backup: a directory on your host to store the backup in, and the volumes from the container we just stopped so we can access the data.
```bash
docker run --rm -v /path/to/backups:/backups --volumes-from phpfpm busybox \
cp -a /bitnami/phpfpm /backups/latest
cp -a /bitnami/php /backups/latest
```
or using Docker Compose:
```bash
docker run --rm -v /path/to/backups:/backups --volumes-from `docker-compose ps -q phpfpm` busybox \
cp -a /bitnami/phpfpm /backups/latest
cp -a /bitnami/php /backups/latest
```
**Note!**
If you only need to backup configuration, you can change the first argument to `cp` to
`/bitnami/php-fpm/conf`.
## Restoring a backup
Restoring a backup is as simple as mounting the backup as volumes in the container.
```bash
docker run -v /path/to/backups/latest/conf:/bitnami/php-fpm/conf \
-v /path/to/backups/latest/logs:/bitnami/php-fpm/logs \
docker run -v /path/to/backups/latest:/bitnami/php \
bitnami/php-fpm
```
@ -322,14 +254,12 @@ or using Docker Compose:
phpfpm:
image: bitnami/php-fpm
volumes:
- /path/to/backups/latest/conf:/bitnami/php-fpm/conf
- /path/to/backups/latest/logs:/bitnami/php-fpm/logs
- /path/to/backups/latest:/bitnami/php
```
## Upgrade this image
Bitnami provides up-to-date versions of PHP-FPM, including security patches, soon after they are
made upstream. We recommend that you follow these steps to upgrade your container.
Bitnami provides up-to-date versions of PHP-FPM, including security patches, soon after they are made upstream. We recommend that you follow these steps to upgrade your container.
### Step 1: Get the updated image
@ -360,8 +290,7 @@ docker-compose rm -v phpfpm
### Step 4: Run the new image
Re-create your container from the new image, [restoring your backup](#restoring-a-backup) if
necessary.
Re-create your container from the new image, [restoring your backup](#restoring-a-backup) if necessary.
```bash
docker run --name phpfpm bitnami/php-fpm:latest
@ -375,15 +304,18 @@ docker-compose start phpfpm
# Testing
This image is tested for expected runtime behavior, using the
[Bats](https://github.com/sstephenson/bats) testing framework. You can run the tests on your machine
using the `bats` command.
This image is tested for expected runtime behavior, using the [Bats](https://github.com/sstephenson/bats) testing framework. You can run the tests on your machine using the `bats` command.
```
bats test.sh
```
# Changelog
# Notable Changes
## 7.0.6-r0 (2016-05-17)
- All volumes have been merged at `/bitnami/php`. Now you only need to mount a single volume at `/bitnami/php` for persistence.
- The logs are always sent to the `stdout` and are no longer collected in the volume.
## 5.5.30-2 (2015-12-07)
@ -391,7 +323,7 @@ bats test.sh
## 5.5.30-0-r01 (2015-11-10)
- `php.ini` is now exposed in the volume mounted at `/bitnami/php-fpm/conf/` allowing users to change the defaults as per their requirements.
- `php.ini` is now exposed in the volume mounted at `/bitnami/php/conf/` allowing users to change the defaults as per their requirements.
## 5.5.30-0 (2015-10-06)
@ -399,22 +331,17 @@ bats test.sh
# Contributing
We'd love for you to contribute to this Docker image. You can request new features by creating an
[issue](https://github.com/bitnami/bitnami-docker-php-fpm/issues), or submit a
[pull request](https://github.com/bitnami/bitnami-docker-php-fpm/pulls) with your contribution.
We'd love for you to contribute to this Docker image. You can request new features by creating an [issue](https://github.com/bitnami/bitnami-docker-php-fpm/issues), or submit a [pull request](https://github.com/bitnami/bitnami-docker-php-fpm/pulls) with your contribution.
# Issues
If you encountered a problem running this container, you can file an
[issue](https://github.com/bitnami/bitnami-docker-php-fpm/issues). For us to provide better support,
be sure to include the following information in your issue:
If you encountered a problem running this container, you can file an [issue](https://github.com/bitnami/bitnami-docker-php-fpm/issues). For us to provide better support, be sure to include the following information in your issue:
- Host OS and version
- Docker version (`docker version`)
- Output of `docker info`
- Version of this container (`echo $BITNAMI_APP_VERSION` inside the container)
- The command you used to run the container, and any relevant output you saw (masking any sensitive
information)
- The command you used to run the container, and any relevant output you saw (masking any sensitive information)
# License

View File

@ -1,17 +0,0 @@
$BITNAMI_APP_NAME cheatsheet:
VOLUMES:
/app: Default work directory for your $BITNAMI_APP_NAME application.
$BITNAMI_APP_VOL_PREFIX/conf: Location of php-fpm.conf ($BITNAMI_APP_NAME config file).
$BITNAMI_APP_VOL_PREFIX/logs: Location of $BITNAMI_APP_NAME logs.
PORTS:
9000: Port exposed by container. Please configure your $BITNAMI_APP_NAME app to use this port.
COMMANDS:
print-help: Print this page.
check-updates: Check if a new version of the $BITNAMI_APP_NAME image is available.
Visit $GITHUB_PAGE for more information.

View File

@ -1,6 +0,0 @@
volumes:
/app: "Default work directory for your $BITNAMI_APP_NAME application."
$BITNAMI_APP_VOL_PREFIX/conf: "Location of php-fpm.conf ($BITNAMI_APP_NAME config file)."
$BITNAMI_APP_VOL_PREFIX/logs: "Location of $BITNAMI_APP_NAME logs."
ports:
9000: "Port exposed by container. Please configure your $BITNAMI_APP_NAME app to use this port."

View File

@ -1 +0,0 @@
Hi!

View File

@ -1 +0,0 @@
4a46fe104952e26580cffdee198f023ebb4b001db2a2f3e6a995e10abb5510b8 /tmp/installer.run

View File

@ -1,16 +0,0 @@
#!/bin/bash
mkdir /app
# set up default config
mkdir $BITNAMI_APP_DIR/etc/conf.defaults
mkdir $BITNAMI_APP_DIR/etc/conf
mv $BITNAMI_APP_DIR/etc/php-fpm.conf $BITNAMI_APP_DIR/etc/conf.defaults
ln -s $BITNAMI_APP_DIR/etc/conf/php-fpm.conf $BITNAMI_APP_DIR/etc/php-fpm.conf
# Temp fix for disabling php-fpm caching
sudo sed --follow-symlinks -i -e 's/\(opcache\.enable=\)1/\10/g' $BITNAMI_PREFIX/php/etc/php.ini
mv $BITNAMI_APP_DIR/etc/php.ini $BITNAMI_APP_DIR/etc/conf.defaults
ln -s $BITNAMI_APP_DIR/etc/conf/php.ini $BITNAMI_APP_DIR/etc/php.ini
chown -R $BITNAMI_APP_USER:$BITNAMI_APP_USER /app/ $BITNAMI_APP_DIR/etc/conf $BITNAMI_APP_DIR/var/log
ln -s $BITNAMI_APP_DIR/var/log $BITNAMI_APP_VOL_PREFIX/logs
ln -s $BITNAMI_APP_DIR/etc/conf $BITNAMI_APP_VOL_PREFIX/conf

View File

@ -0,0 +1,13 @@
#!/bin/bash
set -e
if [[ "$1" == "harpoon" && "$2" == "start" ]]; then
status=`harpoon inspect $BITNAMI_APP_NAME`
if [[ "$status" == *'"lifecycle": "unpacked"'* ]]; then
harpoon initialize $BITNAMI_APP_NAME
fi
fi
chown $BITNAMI_APP_USER: /bitnami/$BITNAMI_APP_NAME || true
exec /entrypoint.sh "$@"

View File

@ -1,12 +0,0 @@
#!/usr/bin/with-contenv bash
set -e
source $BITNAMI_PREFIX/bitnami-utils.sh
if [ ! "$(ls -A $BITNAMI_APP_VOL_PREFIX/conf)" ]; then
generate_conf_files $BITNAMI_APP_DIR/etc
fi
sudo chown -R $BITNAMI_APP_USER:$BITNAMI_APP_USER \
$BITNAMI_APP_VOL_PREFIX/conf/ \
$BITNAMI_APP_VOL_PREFIX/logs/ \
/app || true

View File

@ -1,21 +0,0 @@
#!/usr/bin/with-contenv bash
failcount=0
if [ -f $BITNAMI_APP_DIR/tmp/failcount ]; then
failcount=$(cat $BITNAMI_APP_DIR/tmp/failcount)
fi
start=$(cat $BITNAMI_APP_DIR/tmp/start)
stop=`date '+%d%H%M%S'`
interval=`expr $stop - $start`
if test $interval -lt 30 ; then
failcount=`expr $failcount + 1`
else
failcount=0
fi
echo -n $failcount > $BITNAMI_APP_DIR/tmp/failcount
# bring down container on frequent failures. something is definitely wrong
if test $failcount -ge 3 ; then
s6-svscanctl -t /var/run/s6/services
fi

View File

@ -1,7 +0,0 @@
#!/usr/bin/with-contenv bash
set -e
source $BITNAMI_PREFIX/bitnami-utils.sh
mkdir -p $BITNAMI_APP_DIR/tmp
date '+%d%H%M%S' > $BITNAMI_APP_DIR/tmp/start
exec s6-setuidgid $BITNAMI_APP_USER $BITNAMI_APP_DAEMON -F ${EXTRA_OPTIONS:+"$EXTRA_OPTIONS"}

View File

@ -4,10 +4,11 @@ NGINX_IMAGE_NAME=bitnami/nginx
NGINX_CONTAINER_NAME=bitnami-nginx-test
# source the helper script
APP_NAME=php-fpm
SLEEP_TIME=3
APP_NAME=php
IMAGE_NAME=bitnami/php-fpm
SLEEP_TIME=10
VOL_PREFIX=/bitnami/$APP_NAME
VOLUMES=/app:$VOL_PREFIX/logs:$VOL_PREFIX/conf
VOLUMES=$VOL_PREFIX
load tests/docker_helper
# Cleans up all running/stopped containers and host mounted volumes
@ -26,15 +27,6 @@ teardown() {
# cleanup the environment of any leftover containers and volumes before starting the tests
cleanup_environment
@test "php and php-fpm installed" {
container_create default -d
run container_exec default php -v
[ "$status" = 0 ]
run container_exec default php-fpm -v
[ "$status" = 0 ]
}
create_nginx_container() {
docker run --name $NGINX_CONTAINER_NAME -d \
$(container_link default $APP_NAME) $NGINX_IMAGE_NAME
@ -55,6 +47,15 @@ EOF"
sleep $SLEEP_TIME
}
@test "php and php-fpm installed" {
container_create default -d
run container_exec default php -v
[ "$status" = 0 ]
run container_exec default php-fpm -v
[ "$status" = 0 ]
}
@test "winter is coming via nginx" {
container_create default -d
@ -69,11 +70,12 @@ EOF"
[[ "$output" =~ "Winter is coming" ]]
}
@test "required volumes exposed" {
@test "All the volumes exposed" {
container_create default -d
# get container introspection details and check if volumes are exposed
run container_inspect default --format {{.Mounts}}
[[ "$output" =~ "$VOL_PREFIX/logs" ]]
[[ "$output" =~ "$VOL_PREFIX/conf" ]]
[[ "$output" =~ "$VOL_PREFIX" ]]
}
@test "Data gets generated in conf if bind mounted in the host" {
@ -83,19 +85,39 @@ EOF"
run container_exec default ls -la $VOL_PREFIX/conf/
[[ "$output" =~ "php-fpm.conf" ]]
[[ "$output" =~ "php.ini" ]]
}
# files expected in logs volume
run container_exec default ls -la $VOL_PREFIX/conf/ $VOL_PREFIX/logs/
[[ "$output" =~ "php-fpm.log" ]]
@test "Configuration changes are preserved after restart" {
container_create default -d
# modify php-fpm.conf
container_exec default sed -i 's|^[#]*[ ]*pm.max_children[ ]*=.*|pm.max_children=10|' $VOL_PREFIX/conf/php-fpm.d/www.conf
container_exec default sed -i 's|^[#]*[ ]*pm.start_servers[ ]*=.*|pm.start_servers=5|' $VOL_PREFIX/conf/php-fpm.d/www.conf
container_exec default sed -i 's|^[#]*[ ]*pm.min_spare_servers[ ]*=.*|pm.min_spare_servers=3|' $VOL_PREFIX/conf/php-fpm.d/www.conf
# modify php.ini
container_exec default sed -i 's|^[;]*[ ]*soap.wsdl_cache_limit[ ]*=.*|soap.wsdl_cache_limit=10|' $VOL_PREFIX/conf/php.ini
container_exec default sed -i 's|^[;]*[ ]*opcache.enable[ ]*=.*|opcache.enable=1|' $VOL_PREFIX/conf/php.ini
container_restart default
run container_exec default cat $VOL_PREFIX/conf/php-fpm.d/www.conf
[[ "$output" =~ "pm.max_children=10" ]]
[[ "$output" =~ "pm.start_servers=5" ]]
[[ "$output" =~ "pm.min_spare_servers=3" ]]
run container_exec default cat $VOL_PREFIX/conf/php.ini
[[ "$output" =~ "soap.wsdl_cache_limit=10" ]]
[[ "$output" =~ "opcache.enable=1" ]]
}
@test "Configuration changes are preserved after deletion" {
container_create_with_host_volumes default -d
# modify php-fpm.conf
container_exec default sed -i 's|^[#]*[ ]*pm.max_children[ ]*=.*|pm.max_children=10|' $VOL_PREFIX/conf/php-fpm.conf
container_exec default sed -i 's|^[#]*[ ]*pm.start_servers[ ]*=.*|pm.start_servers=5|' $VOL_PREFIX/conf/php-fpm.conf
container_exec default sed -i 's|^[#]*[ ]*pm.min_spare_servers[ ]*=.*|pm.min_spare_servers=3|' $VOL_PREFIX/conf/php-fpm.conf
container_exec default sed -i 's|^[#]*[ ]*pm.max_children[ ]*=.*|pm.max_children=10|' $VOL_PREFIX/conf/php-fpm.d/www.conf
container_exec default sed -i 's|^[#]*[ ]*pm.start_servers[ ]*=.*|pm.start_servers=5|' $VOL_PREFIX/conf/php-fpm.d/www.conf
container_exec default sed -i 's|^[#]*[ ]*pm.min_spare_servers[ ]*=.*|pm.min_spare_servers=3|' $VOL_PREFIX/conf/php-fpm.d/www.conf
# modify php.ini
container_exec default sed -i 's|^[;]*[ ]*soap.wsdl_cache_limit[ ]*=.*|soap.wsdl_cache_limit=10|' $VOL_PREFIX/conf/php.ini
@ -107,7 +129,7 @@ EOF"
# relaunch container with host volumes
container_create_with_host_volumes default -d
run container_exec default cat $VOL_PREFIX/conf/php-fpm.conf
run container_exec default cat $VOL_PREFIX/conf/php-fpm.d/www.conf
[[ "$output" =~ "pm.max_children=10" ]]
[[ "$output" =~ "pm.start_servers=5" ]]
[[ "$output" =~ "pm.min_spare_servers=3" ]]