Skip to content
Snippets Groups Projects
Commit a38ce406 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

update docs

parent 585fdcc4
No related branches found
No related tags found
No related merge requests found
# Basic rules
* All files in the `docker/templates/` directory will be processed.
* Do not start with the Teplates! Edit the [init.sh.cfg](10_init.sh.cfg.md) first to define placeholders and variables.
* All files in the `docker/templates/` directory will be processed. This also means: you can add as many custom files here as you want - and the will processed too.
* in the first line must be a line `# TARGET: [name of target file]` to define the target file. If this line does not exist, then the file will be skipped.
* Placeholdrs have the syntax variable in double brackets, i.e. `{{VARNAME}}`
* variables to be replaced are those in docker/init.sh.cfg and `{{genrator}}`
# Templates
## docker-compose.yml
## docker-compose.yml
Main configuration for docker conposer.
## dot_env
Network and servers get a application name as prefix.
**It is not needed to change this file.**
Optional changes:
* if you have more directories than webroot add a mount in the volumes section
```yaml
# TARGET: docker/docker-compose.yml
#
# {{generator}}
#
# ======================================================================
#
# (1) see .env for set variables
# (2) run "docker-compose up" to startup
#
# ======================================================================
version: '3.9'
networks:
{{APP_NAME}}-network:
services:
# ----- apache httpd + php
{{APP_NAME}}-web-server:
build:
context: .
dockerfile: ./containers/web-server/Dockerfile
image: "php:{{APP_PHP_VERSION}}-apache"
container_name: '{{APP_NAME}}-server'
ports:
- '${APP_PORT}:80'
working_dir: ${WEBROOT}
volumes:
- ../:/var/www/${APP_NAME}
- ./containers/web-server/apache/sites-enabled:/etc/apache2/sites-enabled
- ./containers/web-server/php/extra-php-config.ini:/usr/local/etc/php/conf.d/extra-php-config.ini
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost"]
interval: 10s
timeout: 3s
retries: 5
# start_period: 40s
networks:
- {{APP_NAME}}-network
user: ${DOCKER_USER_UID}
# --- 8< --- {{CUTTER_NO_DATABASE}} --- 8< ---
depends_on:
- {{APP_NAME}}-db-server
# ----- mariadb
{{APP_NAME}}-db-server:
image: {{MYSQL_IMAGE}}
container_name: '${APP_NAME}-db'
# restart: always
ports:
- '${DB_PORT}:3306'
environment:
MYSQL_ROOT_PASSWORD: '${MYSQL_ROOT_PASS}'
MYSQL_USER: '${MYSQL_USER}'
MYSQL_PASSWORD: '${MYSQL_PASS}'
MYSQL_DATABASE: '${MYSQL_DB}'
volumes:
# - ./containers/db-server/db_data:/var/lib/mysql
- ./containers/db-server/mariadb/my.cnf:/etc/mysql/conf.d/my.cnf
healthcheck:
test: mysqladmin ping -h 127.0.0.1 -u root --password=$$MYSQL_ROOT_PASSWORD
interval: 5s
retries: 5
networks:
- {{APP_NAME}}-network
```
## ❎ dot_env
The template for `.env` of docker composer.
## web-server-Dockerfile
**It is not needed to change this file.**
```shell
# TARGET: docker/.env
# ======================================================================
#
# {{generator}}
# values to be used in docker-composer.yml
#
# ======================================================================
# ----- application
APP_NAME={{APP_NAME}}
# uid of www-data in the docker container
DOCKER_USER_UID={{DOCKER_USER_UID}}
APP_PORT={{APP_PORT}}
WEBROOT={{WEBROOT}}
# --- 8< --- {{CUTTER_NO_DATABASE}} --- 8< ---
DB_PORT={{DB_PORT}}
# ----- database settings
MYSQL_RANDOM_ROOT_PASSWORD={{MYSQL_RANDOM_ROOT_PASSWORD}}
MYSQL_ALLOW_EMPTY_PASSWORD={{MYSQL_ALLOW_EMPTY_PASSWORD}}
MYSQL_ROOT_PASS={{MYSQL_ROOT_PASS}}
MYSQL_USER={{APP_NAME}}
MYSQL_PASS={{MYSQL_PASS}}
MYSQL_DB={{APP_NAME}}
```
## ❎ Webserver-Dockerfile
Docker container file for Apache httpd and PHP.
It uses the oficial PHP docker images by default.
It uses the oficial PHP docker images by default. It installes given packages
and php modules. To override default module settings see template with "extra-php-config.ini" below.
**It is not needed to change this file.**
```shell
# TARGET: docker/containers/web-server/Dockerfile
#
# {{generator}}
#
FROM php:{{APP_PHP_VERSION}}-apache
# install packages
RUN apt-get update && apt-get install -y {{APP_APT_PACKAGES}}
# enable apache modules
RUN a2enmod {{APP_APACHE_MODULES}}
# install php packages
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
RUN install-php-extensions {{APP_PHP_MODULES}}
```
## vhost_app.conf
## vhost_app.conf
Apache vhost configuration for your app.
**It's a MUST to change this file.**
Setup modules and the vhost including rewrites , ...
## extra-php-config.ini
```txt
# TARGET: docker/containers/web-server/apache/sites-enabled/vhost_app.conf
#
# {{generator}}
#
<VirtualHost *:80>
DocumentRoot {{WEBROOT}}
<Directory {{WEBROOT}}>
AllowOverride None
Order Allow,Deny
Allow from All
</Directory>
# example to prevent access with http
<Location "/no-access">
Require all denied
</Location>
</VirtualHost>
```
## ✳️ extra-php-config.ini
Custom PHP config file for you additional settings.
## my.cnf
✳️ You **SHOULD** change this to setup Mysql database service for your needs.
```ini
# TARGET: docker/containers/web-server/php/extra-php-config.ini
;
; {{generator}}
;
[PHP]
; ----------------------------------------------------------------------
; XDEBUG STUFF BELOW
; ----------------------------------------------------------------------
;
; error_reporting=E_ALL
;
; [xdebug]
; xdebug.mode=develop,debug
; ; xdebug.client_host=localhost
; xdebug.start_with_request=yes
; ; xdebug.start_with_request=trigger
;
; xdebug.log=/tmp/xdebug.log
; xdebug.discover_client_host = 1
; ; xdebug.client_port=9003
; xdebug.idekey="netbeans-xdebug"
```
## ✳️ my.cnf
If you use a Mariadb a 2nd container will be initialized using this my.cnf.
✳️ You **SHOULD** change this to setup Mysql database service for your needs.
```ini
# TARGET: docker/containers/db-server/mariadb/my.cnf
[mysqld]
; collation-server = utf8mb4_unicode_ci
; character-set-server = utf8mb4
```
\ No newline at end of file
......@@ -3,7 +3,7 @@
"author": "Axel Hahn",
"tagline": "Bring up a docker container with a PHP 8.x dev environment",
"ignore": {
"files": ["30_PHP-client/Plugins/Checks/_skeleton.md"],
"files": ["_skeleton.md"],
"folders": ["99_Not_Ready"]
},
"html": {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment