Sign inSign up

johanmarx/stratusolve_php_apache

By johanmarx

•Updated over 1 year ago

Image
0

10K+

johanmarx/stratusolve_php_apache repository overview

⁠What is this image?

This image was created for the divblox⁠ and sDev frameworks at stratuSolve⁠.

It is based on the php:**-apache image⁠ and has everything you need to run the application.

This image contains the following:

  • Apache2 with relevant modules
  • Latest PHP version with relevant extentions
  • qpdf⁠ for PDF utilities

⁠PHP Versions

PHP 8.0 - Tags
  • 221019
  • 221208
  • 230328
  • 230614

PHP 8.2 - Tags
  • php802010-231114
  • php802015-240214
  • php802018-240422
  • php802024-241009

⁠How to use locally

The easiest way to setup the environment is to use Docker Compose⁠. This will allow us to quickly connect our webserver and database without manually creating a network between them.
A prerequisite is that your current user should be in the 'docker' group. You can use sudo usermod -aG docker $USER to achieve this.

⁠sDev Example

sDev with TLS termination, MySQL 8.0 and Redis for state
⁠Caddyfile
customdomain.sdev.local {
    reverse_proxy sdev:80
    tls internal
}
⁠docker-compose.yml
version: '3'
services:
    caddy:
        image: caddy:latest
        ports:
            - 80:80
            - 443:443
            - 443:443/udp
        volumes:
            - ./Caddyfile:/etc/caddy/Caddyfile
            - caddy_data:/data
            - caddy_config:/config
    sdev:
        image: johanmarx/stratusolve_php_apache:latest
        volumes:
            - ./src:/var/www/html/ #bind your source
        extra_hosts:
            - customdomain.sdev.local:host-gateway
        environment:
            - SERVER_INSTANCE=container
            - BEHIND_SECURE_GATEWAY=1
            - ALLOW_REMOTE_ADMIN=1
            - DEV_MODE=1
            - DB_SERVER=sql
            - DB_NAME=dxdatabase
            - DB_USERNAME=dxuser
            - DB_PASSWORD=secret
            - MAINTENANCE_PASS=123
            - NON_PROD_INDICATOR=Top
            - REDIS_HOST=redis
            - REDIS_PORT=6379
            - REDIS_PASSWORD=123
            - PHP_SESSION_HANDLER=files
            - PHP_SESSION_PATH=/tmp
    sql:
        image: mysql:8.0
        environment: 
            MYSQL_ROOT_PASSWORD: 'secret'
            MYSQL_USER: 'dxuser'
            MYSQL_PASSWORD: 'secret'
            MYSQL_DATABASE: 'dxdatabase'
        volumes: 
            - mysql8data:/var/lib/mysql
        command:
            - --default-authentication-plugin=caching_sha2_password
            - --lower_case_table_names=1
            - --sql_mode=
        ports:
            - 3306:3306
    redis:
        image: redis:latest
        ports:
            - 6379:6379
        command: redis-server --save 60 10 --requirepass 123
        volumes:
            - reddis_data:/data
volumes: 
   mysql8data: {}
   caddy_data: {}
   caddy_config: {}
   reddis_data: {}

⁠divbloxPHP Example

divbloxPHP with TLS termination, MySQL 8.0, Redis for state and MemcacheD for Sessions
⁠Caddyfile
customdomain.divblox.local {
    reverse_proxy divblox:80
    tls internal
}
⁠docker-compose.yml
version: "3"
services:
    caddy:
        image: caddy:latest
        ports:
            - 80:80
            - 443:443
            - 443:443/udp
        volumes:
            - ./Caddyfile:/etc/caddy/Caddyfile
            - caddy_data:/data
            - caddy_config:/config
    divblox:
        image: johanmarx/stratusolve_php_apache:latest
        volumes:
            - ./src:/var/www/html/ #bind your source
        environment:
            - CONTAINER=1
            - BEHIND_SECURE_GATEWAY=1
            - DB_SERVER=sql
            - DB_PORT=3306
            - DB_NAME=dxdatabase
            - DB_USERNAME=dxuser
            - DB_PASSWORD=secret
            - MAINTENANCE_USERNAME=admin
            - MAINTENANCE_PASSWORD=123
            - REDIS_STATE=1
            - REDIS_HOST=redis
            - REDIS_PORT=6379
            - REDIS_PASSWORD=123
            - DX_API_KEY=adummyapikey
            - PHP_SESSION_HANDLER=memcached
            - PHP_SESSION_PATH=memcached:11211
        extra_hosts:
            - customdomain.divblox.local:host-gateway
    sql:
        image: mysql:8.0
        environment:
            MYSQL_ROOT_PASSWORD: "secret"
            MYSQL_USER: "dxuser"
            MYSQL_PASSWORD: "secret"
            MYSQL_DATABASE: "dxdatabase"
        volumes:
            - mysql8data:/var/lib/mysql
        command:
            - --default-authentication-plugin=caching_sha2_password
            - --lower_case_table_names=1
            - --sql_mode=
        ports:
            - 3306:3306
    redis:
        image: redis:latest
        ports:
            - 6379:6379
        command: redis-server --save 60 10 --requirepass 123
        volumes:
            - reddis_data:/data
    memcached:
        image: memcached:1.6.22-alpine
        ports:
            - 11211:11211
volumes:
    mysql8data: {}
    caddy_data: {}
    caddy_config: {}
    reddis_data: {}

⁠How to set up custom domains

You can navigate to your machine's hosts file, then add the following lines based on the framework:

127.0.0.1   customdomain.divblox.local
127.0.0.1   customdomain.sdev.local

You might have to restart after this for it to take effect.

You can ping the domain to check that you get responses from 127.0.0.1

ping customdomain.divblox.local

Linux /etc/hosts
macOS /private/etc/hosts
Windows: c:\windows\system32\drivers\etc\hosts.file

⁠Session Manager Options (>= php802010-231114 only)

You must use one of the following sets of environment variables to define where your PHP sessions are managed.
Note that this has to correspond with the rest of your setup.

MemcacheD⁠

PHP_SESSION_HANDLER=memcached
PHP_SESSION_PATH=memcached:11211

Redis⁠

PHP_SESSION_HANDLER=redis
PHP_SESSION_PATH=tcp://redis:6379?auth=123

Temporary File (old default, all sessions lost on app container restart)

PHP_SESSION_HANDLER=files
PHP_SESSION_PATH=/tmp

⁠Debugging with Xdebug

You can use Xdebug⁠ to debug your application. By using an Xdebug Dockerfile and a new php.ini you can build an image to replace this base image.

⁠Xdebug.Dockerfile
FROM johanmarx/stratusolve_php_apache:latest

COPY ./xdebug.ini "$PHP_INI_DIR/conf.d"

⁠xdebug.ini
[xdebug]
zend_extension=xdebug
xdebug.mode=develop,debug
xdebug.start_with_request=yes
xdebug.discover_client_host=0
xdebug.client_host=host.docker.internal
xdebug.client_port=9003
⁠docker-compose.yml
service_name:
    build:
        context: .
        dockerfile: Xdebug.Dockerfile
    image: customxdebugimage
    # image: johanmarx/stratusolve_php_apache:latest
    volumes:
        - ./src:/var/www/html
    extra_hosts:
        - host.docker.internal:host-gateway #important
        - ...
    env_file:
        - local.env

You can then listen for debug connections on VSCode or PhpStorm on port 9003.

Tag summary

Content type

Image

Digest

sha256:ca6763b1e…

Size

302.1 MB

Last updated

over 1 year ago

docker pull johanmarx/stratusolve_php_apache