Skip to content

Commit badd757

Browse files
committed
example dhi
example config with DHI for WSC
1 parent b805daa commit badd757

File tree

5 files changed

+170
-0
lines changed

5 files changed

+170
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
11
temp/
2+
examples/**/.env
3+
examples/**/data
4+
examples/**/data-*
5+
examples/**/data_*
6+
examples/**/html/**

examples/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# PHP - Examples
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# General
2+
DOMAIN=example.com
3+
# Database (MySQL/MariaDB)
4+
MYSQL_ROOT_PASSWORD=my-secret-pw
5+
MYSQL_DATABASE=woltlab_suite
6+
MYSQL_USER=woltlab_suite
7+
MYSQL_PASSWORD=my-secret-pw
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# enable ONLY behind PROXY (Traefik, other NGINX, Caddy, lighttpd, K8s Ingress, ...) (ngx_http_realip_module)
2+
set_real_ip_from 172.16.0.0/12;
3+
set_real_ip_from fd00::/8;
4+
real_ip_header X-Forwarded-For;
5+
6+
# Server (http)
7+
server {
8+
listen 8080;
9+
listen [::]:8080;
10+
server_name _;
11+
12+
# disable any limits to avoid HTTP 413 for large image uploads
13+
client_max_body_size 0;
14+
15+
# nginx status
16+
location /nginx_status {
17+
stub_status on;
18+
access_log off;
19+
allow 127.0.0.1;
20+
allow 10.0.0.0/8;
21+
allow 172.16.0.0/12;
22+
allow 192.168.0.0/16;
23+
allow ::1;
24+
allow fd00::/8;
25+
deny all;
26+
}
27+
28+
# Error Page
29+
location @error_page {
30+
add_header Content-Type text/plain;
31+
return 200 'Website is in maintenance mode!)';
32+
}
33+
34+
root /var/www/html;
35+
index index.php index.html test.php;
36+
37+
location / {
38+
#root /var/www/html;
39+
#index index.php index.html;
40+
41+
try_files $uri $uri/ /index.php?$query_string;
42+
}
43+
44+
location ~ \.php$ {
45+
#root /var/www/html;
46+
47+
try_files $uri =404;
48+
49+
fastcgi_pass wsc-dhi-php:9000;
50+
fastcgi_index index.php;
51+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
52+
include fastcgi_params;
53+
54+
# Error Page (redirect)
55+
error_page 502 503 504 = @error_page;
56+
}
57+
58+
location ~ /\.ht {
59+
deny all;
60+
}
61+
#location = /favicon.ico { log_not_found off; access_log off; }
62+
#location = /robots.txt { log_not_found off; access_log off; }
63+
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
services:
2+
3+
# https://github.com/Tob1as/docker-php
4+
# based on: https://dhi.io/catalog/php
5+
# command: mkdir ./html && chown 65532:65532 ./html
6+
wsc-php:
7+
image: docker.io/tobi312/php:8.4-dhi-fpm-debian-wsc
8+
#image: docker.io/tobi312/php:8.4-dhi-fpm-alpine-wsc
9+
container_name: wsc-php
10+
restart: unless-stopped
11+
volumes:
12+
- ./html:/var/www/html:rw
13+
#depends_on:
14+
# wsc-db:
15+
# condition: service_started
16+
networks:
17+
- wsc-net
18+
19+
# https://dhi.io/catalog/nginx
20+
wsc-nginx:
21+
image: dhi.io/nginx:1.29-debian13
22+
container_name: wsc-nginx
23+
restart: unless-stopped
24+
#ports:
25+
# - "80:8080"
26+
volumes:
27+
- ./html:/var/www/html:rw
28+
- ./config/nginx_default.conf:/etc/nginx/conf.d/default.conf:ro
29+
depends_on:
30+
wsc-php:
31+
condition: service_started
32+
networks:
33+
- wsc-net
34+
- traefik
35+
labels:
36+
# Explicitly tell Traefik to expose this container
37+
- "traefik.enable=true"
38+
- "traefik.docker.network=traefik"
39+
# Tell Traefik to use the http port 8080 to connect to container
40+
- "traefik.http.services.wsc.loadbalancer.server.port=8080"
41+
- "traefik.http.services.wsc.loadbalancer.server.scheme=http" # when "https" then set "--serversTransport.insecureSkipVerify=true" for traefik
42+
# http
43+
- "traefik.http.routers.wsc-http.rule=Host(`${DOMAIN}`)"
44+
- "traefik.http.routers.wsc-http.entrypoints=web"
45+
- "traefik.http.routers.wsc-http.service=wsc"
46+
# https
47+
- "traefik.http.routers.wsc-https.tls=true"
48+
- "traefik.http.routers.wsc-https.rule=Host(`${DOMAIN}`)"
49+
- "traefik.http.routers.wsc-https.entrypoints=websecure"
50+
- "traefik.http.routers.wsc-https.service=wsc"
51+
# load middlewares for routes
52+
- "traefik.http.routers.wsc-http.middlewares=wsc-https"
53+
#- "traefik.http.routers.wsc-https.middlewares="
54+
# http to https redirect
55+
- "traefik.http.middlewares.wsc-https.redirectscheme.scheme=https"
56+
- "traefik.http.middlewares.wsc-https.redirectscheme.permanent=true"
57+
#- "traefik.http.middlewares.wsc-https.redirectscheme.port=443"
58+
59+
# https://dhi.io/catalog/mysql
60+
# command: mkdir ./data-db && chown 65532:65532 ./data-db
61+
wsc-db:
62+
image: dhi.io/mysql:8.4-debian13
63+
container_name: wsc-db
64+
restart: unless-stopped
65+
volumes:
66+
- ./data-db:/var/lib/mysql:rw
67+
environment:
68+
MYSQL_ROOT_PASSWORD: "${MYSQL_ROOT_PASSWORD}"
69+
# only support in DHI (instead of own *.cnf file)
70+
MYSQL_OPTIONS: "--innodb-buffer-pool-size=512M"
71+
# not supported in DHI, but for commands to create database and user
72+
MYSQL_DATABASE: "${MYSQL_DATABASE}"
73+
MYSQL_USER: "${MYSQL_USER}"
74+
MYSQL_PASSWORD: "${MYSQL_PASSWORD}"
75+
#ports:
76+
# - 127.0.0.1:3060:3306/tcp
77+
# - 127.0.0.1:33060:33060/tcp
78+
networks:
79+
wsc-net:
80+
aliases:
81+
- wsc-database
82+
- wsc-mysql
83+
- wsc-mariadb
84+
# TODO: only do this commands after first start when using dhi mysql image (create database and user with password form environment vars):
85+
# docker exec -it wsc-mysql bash -c 'mysql -uroot -e "CREATE DATABASE ${MYSQL_DATABASE};"'
86+
# docker exec -it wsc-mysql bash -c 'mysql -uroot -e "CREATE USER \"${MYSQL_USER}\"@\"%\" IDENTIFIED BY \"${MYSQL_PASSWORD}\"; GRANT ALL PRIVILEGES ON ${MYSQL_DATABASE}.* TO \"${MYSQL_USER}\"@\"%\";"'
87+
88+
89+
networks:
90+
wsc-net:
91+
name: wsc-net
92+
traefik:
93+
name: traefik
94+
external: true

0 commit comments

Comments
 (0)