Skip to content

Commit 2f54630

Browse files
committed
examples
1 parent cf2716d commit 2f54630

File tree

3 files changed

+279
-8
lines changed

3 files changed

+279
-8
lines changed

docker-compose.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@ version: "2.4"
22

33
services:
44

5-
php: # or: website
5+
website:
66
#build:
77
# context: ./
88
# dockerfile: debian.apache.Dockerfile
9-
image: tobi312/php:8.4-apache-debian
10-
#image: tobi312/php:8.4-fpm-nginx-alpine
11-
container_name: phpcontainer # or: website
12-
#restart: unless-stopped
9+
image: docker.io/tobi312/php:8.4-apache-debian # or: docker.io/tobi312/php:8.4-apache-debian-wsc
10+
#image: docker.io/tobi312/php:8.4-fpm-nginx-alpine # or: docker.io/tobi312/php:8.4-fpm-nginx-alpine-wsc
11+
container_name: website
12+
restart: unless-stopped
1313
## ports ONLY with apache/nginx:
1414
ports:
1515
- "80:80"
1616
- "443:443"
1717
volumes:
18-
#- apache-data:/var/www/html:rw
18+
#- website-data:/var/www/html:rw
1919
- ./html:/var/www/html:rw
2020
## optional: folder with own entrypoint-file(s) mount:
2121
#- ./entrypoint.d:/entrypoint.d:ro
@@ -32,6 +32,7 @@ services:
3232
PHP_UPLOAD_MAX_FILESIZE: 250
3333
PHP_MAX_FILE_UPLOADS: 20
3434
PHP_MAX_EXECUTION_TIME: 120
35+
PHP_SET_OPCACHE_SETTINGS: 0
3536
CREATE_PHPINFO_FILE: 0
3637
CREATE_INDEX_FILE: 0
3738
## next env only with php-fpm
@@ -101,4 +102,4 @@ networks:
101102

102103

103104
#volumes:
104-
# apache-data:
105+
# website-data:

examples/apache/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ services:
44
# based on: https://hub.docker.com/_/php (https://github.com/docker-library/php)
55
# command: mkdir ./html && chown 33:33 ./html
66
wsc-php:
7-
image: docker.io/tobi312/php:8.4-apache-wsc
7+
image: docker.io/tobi312/php:8.4-apache-debian-wsc
88
container_name: wsc-php
99
restart: unless-stopped
1010
#ports:

k8s.yaml

Lines changed: 270 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,270 @@
1+
# Website (PHP)
2+
# Source: https://github.com/Tob1as/docker-php
3+
4+
# upload/copy your files to webfolder:
5+
# kubectl -n website cp ./upload/. $(kubectl -n website get pod -l app.kubernetes.io/name=website -o jsonpath="{.items[0].metadata.name}"):/var/www/html/ -c website
6+
7+
---
8+
9+
# Recommended: After the initial installation, comment Namespace out to protect it from deletion by mistake.
10+
11+
apiVersion: v1
12+
kind: Namespace
13+
metadata:
14+
name: website
15+
16+
---
17+
18+
# Recommended: After the initial installation, comment PVC out to protect it from deletion by mistake.
19+
20+
apiVersion: v1
21+
kind: PersistentVolumeClaim
22+
metadata:
23+
name: website-data
24+
namespace: website
25+
labels:
26+
app.kubernetes.io/name: website
27+
app.kubernetes.io/component: server
28+
app.kubernetes.io/part-of: website
29+
spec:
30+
accessModes:
31+
- ReadWriteOnce
32+
volumeMode: Filesystem
33+
storageClassName: local-path # set to your class
34+
resources:
35+
requests:
36+
storage: 15Gi
37+
38+
---
39+
40+
apiVersion: v1
41+
kind: ConfigMap
42+
metadata:
43+
name: website-env-config
44+
namespace: website
45+
labels:
46+
app.kubernetes.io/name: website
47+
app.kubernetes.io/component: server
48+
app.kubernetes.io/part-of: website
49+
data:
50+
TZ: "Europe/Berlin"
51+
PHP_ERRORS: "1"
52+
PHP_MEM_LIMIT: "128"
53+
PHP_POST_MAX_SIZE: "250"
54+
PHP_UPLOAD_MAX_FILESIZE: "250"
55+
PHP_MAX_FILE_UPLOADS: "20"
56+
PHP_MAX_EXECUTION_TIME: "120"
57+
PHP_SET_OPCACHE_SETTINGS: "0"
58+
CREATE_PHPINFO_FILE: "0"
59+
CREATE_INDEX_FILE: "0"
60+
## next env only with php-fpm
61+
#ENABLE_PHP_FPM_STATUS: "1"
62+
## next env only with apache
63+
ENABLE_APACHE_REWRITE: "1"
64+
ENABLE_APACHE_ACTIONS: "0"
65+
ENABLE_APACHE_SSL: "0"
66+
ENABLE_APACHE_HEADERS: "0"
67+
ENABLE_APACHE_ALLOWOVERRIDE: "1"
68+
ENABLE_APACHE_REMOTEIP: "1"
69+
ENABLE_APACHE_STATUS: "1"
70+
#ENABLE_APACHE_SSL_REDIRECT: "0"
71+
#APACHE_SERVER_NAME: ""
72+
#APACHE_SERVER_ALIAS: ""
73+
#APACHE_SERVER_ADMIN: ""
74+
DISABLE_APACHE_DEFAULTSITES: "0"
75+
## next env only with nginx
76+
#ENABLE_NGINX_REMOTEIP: "1"
77+
#ENABLE_NGINX_STATUS: "1"
78+
79+
#---
80+
#
81+
## when you want using "data" instead "stringData" then ...
82+
## convert string to base64 in Linux: "echo -n 'value' | base64"
83+
#
84+
#apiVersion: v1
85+
#kind: Secret
86+
#metadata:
87+
# name: website-env-secret
88+
# namespace: website
89+
# labels:
90+
# app.kubernetes.io/name: website
91+
# app.kubernetes.io/component: server
92+
# app.kubernetes.io/part-of: website
93+
#stringData:
94+
# MY_SECRET_ENV: "my-secret"
95+
96+
---
97+
98+
apiVersion: apps/v1
99+
kind: Deployment
100+
metadata:
101+
name: website
102+
namespace: website
103+
labels:
104+
app.kubernetes.io/name: website
105+
app.kubernetes.io/component: server
106+
app.kubernetes.io/part-of: website
107+
spec:
108+
replicas: 1
109+
strategy:
110+
type: Recreate
111+
selector:
112+
matchLabels:
113+
app.kubernetes.io/name: website
114+
app.kubernetes.io/component: server
115+
app.kubernetes.io/part-of: website
116+
template:
117+
metadata:
118+
labels:
119+
app.kubernetes.io/name: website
120+
app.kubernetes.io/component: server
121+
app.kubernetes.io/part-of: website
122+
spec:
123+
#hostname: website
124+
#imagePullSecrets:
125+
#- name: regcred-dockerhub
126+
restartPolicy: Always
127+
#securityContext:
128+
# fsGroup: 33 # 33 for apache or 82 for alpine
129+
containers:
130+
- name: website
131+
image: docker.io/tobi312/php:8.4-apache # or: docker.io/tobi312/php:8.4-apache-debian-wsc
132+
#image: docker.io/tobi312/php:8.4-fpm-nginx-alpine # or: docker.io/tobi312/php:8.4-fpm-nginx-alpine-wsc
133+
imagePullPolicy: Always
134+
envFrom:
135+
- configMapRef:
136+
name: website-env-config
137+
#optional: true
138+
- secretRef:
139+
name: website-env-secret
140+
optional: true
141+
ports:
142+
- containerPort: 80
143+
name: http
144+
protocol: TCP
145+
- containerPort: 443
146+
name: https
147+
protocol: TCP
148+
readinessProbe:
149+
#httpGet:
150+
# path: /server-status # /server-status or /nginx_ping
151+
# port: 80
152+
# scheme: HTTP
153+
tcpSocket:
154+
port: 80
155+
initialDelaySeconds: 10
156+
periodSeconds: 30
157+
timeoutSeconds: 5
158+
failureThreshold: 3
159+
successThreshold: 1
160+
livenessProbe:
161+
#httpGet:
162+
# path: /server-status # /server-status or /nginx_ping
163+
# port: 80
164+
# scheme: HTTP
165+
tcpSocket:
166+
port: 80
167+
initialDelaySeconds: 10
168+
periodSeconds: 30
169+
timeoutSeconds: 5
170+
failureThreshold: 3
171+
successThreshold: 1
172+
resources:
173+
requests:
174+
memory: "512Mi"
175+
cpu: "0.5"
176+
limits:
177+
memory: "1Gi"
178+
cpu: "1.0"
179+
volumeMounts:
180+
- name: website-data
181+
mountPath: /var/www/html
182+
initContainers:
183+
# volume-mount-chmod only for first startup or set securityContext->fsGroup
184+
- name: volume-mount-chmod
185+
image: busybox
186+
command: ["sh", "-c", "mkdir -p /var/www/html; chmod 777 /var/www/html; exit"]
187+
volumeMounts:
188+
- name: website-data
189+
mountPath: /var/www/html
190+
resources:
191+
requests:
192+
memory: "128Mi"
193+
cpu: "0.1"
194+
limits:
195+
memory: "128Mi"
196+
cpu: "0.1"
197+
volumes:
198+
- name: website-data
199+
persistentVolumeClaim:
200+
claimName: website-data
201+
202+
---
203+
204+
apiVersion: v1
205+
kind: Service
206+
metadata:
207+
name: website
208+
namespace: website
209+
labels:
210+
app.kubernetes.io/name: website
211+
app.kubernetes.io/component: server
212+
app.kubernetes.io/part-of: website
213+
spec:
214+
type: ClusterIP
215+
ports:
216+
- name: http
217+
protocol: TCP
218+
port: 80
219+
targetPort: 80
220+
#- name: https
221+
# protocol: TCP
222+
# port: 443
223+
# targetPort: 443
224+
selector:
225+
app.kubernetes.io/name: website
226+
app.kubernetes.io/component: server
227+
app.kubernetes.io/part-of: website
228+
229+
---
230+
231+
apiVersion: networking.k8s.io/v1
232+
kind: Ingress
233+
metadata:
234+
name: website
235+
namespace: website
236+
labels:
237+
app.kubernetes.io/name: website
238+
app.kubernetes.io/component: server
239+
app.kubernetes.io/part-of: website
240+
annotations:
241+
## https://cert-manager.io/docs/
242+
#cert-manager.io/cluster-issuer: ingress-tls-secret
243+
#cert-manager.io/acme-challenge-type: http01
244+
## NGINX
245+
#nginx.ingress.kubernetes.io/ssl-redirect: "true"
246+
#nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
247+
nginx.ingress.kubernetes.io/proxy-body-size: "0"
248+
nginx.ingress.kubernetes.io/backend-protocol: "HTTP"
249+
## Traefik
250+
#traefik.ingress.kubernetes.io/router.middlewares: 'website-https-redirectscheme@kubernetescrd'
251+
traefik.ingress.kubernetes.io/router.entrypoints: web,websecure
252+
traefik.ingress.kubernetes.io/service.serversscheme: http
253+
spec:
254+
#ingressClassName: nginx # nginx or traefik or in future "Kubernetes Gateway API"
255+
tls:
256+
- hosts:
257+
- example.com
258+
secretName: ingress-tls-secret
259+
rules:
260+
- host: example.com
261+
http:
262+
paths:
263+
- path: /
264+
pathType: ImplementationSpecific
265+
backend:
266+
service:
267+
name: website
268+
port:
269+
#name: http
270+
number: 80

0 commit comments

Comments
 (0)