Public Repository

Last pushed: 17 days ago
Short Description
Oberon configured PHP application containers
Full Description

Latest PHP 5.6, 7.0 and 7.1 FPM containers compiled with modules used by Oberon server setups:

Additional modules:

  • bcmath
  • exif
  • gd
  • intl
  • mcrypt
  • memcache (php56)
  • memcached
  • mysql (php56)
  • mysqli
  • OPcache
  • redis
  • soap
  • sockets
  • xml
  • xmlrpc
  • xsl
  • zip

Default settings:

date.timezone to "Europe/Amsterdam"
expose_php=off
realpath_cache_ttl=7200
opcache.memory_consumption=32
opcache.enable_cli=1
opcache.enable_file_override=1

Adjustable settings using environment variables:

PHP_MAX_EXECUTION_TIME
PHP_MEMORY_LIMIT
PHP_UPLOAD_LIMIT
PHP_OPCACHE_LIMIT
PHP_OPCACHE_REVALIDATE
PHP_SESSION_SAVE_HANDLER
PHP_SESSION_SAVE_PATH
PHP_SMTP_HOST

Example docker-compose.yml:
web:
    image: jiechin/apache:2.4.25-alpine-fpm
    volumes:
        - .:/app/
    environment:
        - "APACHE_DOCUMENTROOT=/app/web"
    links:
        - php
php:
    image: jiechin/php:7.1-fpm
    volumes:
        - .:/app/
    environment:
        - "PHP_SESSION_SAVE_HANDLER=redis"
        - "PHP_SESSION_SAVE_PATH=tcp://redis:6379"
    links:
        - redis
redis:
    image: redis:3-alpine

Redis:

Using link to redis container and set the sessionhandler to redis and savepath to redis port

Example docker-compose.yml:
php:
    environment:
        - "PHP_SESSION_SAVE_HANDLER=redis"
        - "PHP_SESSION_SAVE_PATH=tcp://redis:6379"
    links:
        - redis
redis:
    image: redis:3-alpine

Sendmail:

Using external_links to docker service, override the default SMTP host using PHP_SMTP_HOST env.

Example docker-compose.yml:
php:
    image: jiechin/php:7.1-fpm
    environment:
        - "PHP_SMTP_HOST=smtp_prod"
    external_links:
        - smtp_prod

Nodejs:

Added nodejs 8.1, npm 5
Preinstalled globally NPM packages: yarn, bower, gulp

[2017-07-19] Added cron and supervisord services

Both services are disabled by default.
To enable cronjobs:

crontab /app/YOUR_CRONFILE
service cron start

To enable supervisor:
Add entry to your volumes in docker-compose.yml:

volumes:
    - ./YOUR_SUPERVISOR.conf:/etc/supervisor/conf.d/PROJECT.conf:ro

And start the supervisord service:

service supervisor start

[2017-07-19] Getting crontabs to work on Docker is a real pain in the *ss...

Add this to your deployment script, this will write all environment vars to file so the cronjobs can access them (for example PHP needs the vars for configuration):

printenv | sed 's/^\(.*\)$/export \1/g' > /root/project_env.sh

Your crontab should look something like this:

SHELL=/bin/bash
* * * * * . /root/project_env.sh; /usr/local/bin/php /app/MYFILE.php 2>&1
# Leave last line empty for cron

Solution found here:
https://ypereirareis.github.io/blog/2016/02/29/docker-crontab-environment-variables/
https://devblog.digimondo.io/how-to-use-environment-variables-in-docker-with-cron-50b20baab430

TODO:

nodejs PM2 server

Docker Pull Command
Owner
jiechin

Comments (0)