Skip to content

Instantly share code, notes, and snippets.

@danopia
Last active April 15, 2025 21:33
Show Gist options
  • Save danopia/e879914b47e70126b38870935c0e4a9a to your computer and use it in GitHub Desktop.
Save danopia/e879914b47e70126b38870935c0e4a9a to your computer and use it in GitHub Desktop.
Kubernetes deployment of dagd
<?php
// Used for the development container, simply to override the db host.
require_once dirname(__FILE__).'/config.dev.php';
DaGdConfig::$config['mysql.host'] = 'db';
DaGdConfig::$config['general.baseurl'] = 'https://dagd.devmode.cloud';
DaGdConfig::$config['session.encryption_key'] = 'insecure production key';
$insights_key = getenv('GOOGLE_INSIGHTS_API');
if ($insights_key !== false) {
DaGdConfig::$config['shorten.google_pagespeed_insights_key'] = $insights_key;
}
FROM alpine
RUN apk add --no-cache \
nginx php-fpm php-pear \
php-curl php-gd php-intl php-json php-mysqli php-mysqlnd
RUN ln -s /usr/sbin/php-fpm* /usr/sbin/php-fpm
RUN pear install Net_DNS2
WORKDIR /srv/dagd
COPY . ./
daemon off;
error_log stderr;
http {
access_log /dev/stdout;
server {
listen 80 default_server;
listen [::]:80 default_server;
root /srv/dagd/src/webroot;
server_name dagd;
location / {
try_files $uri @php;
}
location @php {
fastcgi_pass 127.0.0.1:9000;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
fastcgi_param SCRIPT_NAME /index.php;
fastcgi_param HTTP_X_DAGD_PROXY 1;
fastcgi_param DaGdConfigFile config.kubernetes.php;
}
}
}
events {}
error_reporting = E_ALL
display_errors = Off
apiVersion: apps/v1
kind: Deployment
metadata:
name: dagd-app
spec:
template:
spec:
containers:
- name: nginx
image: dagd
imagePullPolicy: IfNotPresent
command:
- nginx
- -c
- /srv/httpd-conf/nginx.conf
resources:
requests:
memory: 16Mi
cpu: 5m
limits:
memory: 16Mi
cpu: 100m
ports:
- containerPort: 80
name: http
readinessProbe:
periodSeconds: 20
httpGet:
port: http
volumeMounts:
- name: nginx-config
mountPath: /srv/httpd-conf
readOnly: true
- name: php-fpm
image: dagd
imagePullPolicy: IfNotPresent
command:
- php-fpm
- -F
- -O
resources:
requests:
memory: 32Mi
cpu: 10m
limits:
memory: 32Mi
cpu: 500m
volumeMounts:
- name: dagd-config
mountPath: /srv/dagd/src/config.kubernetes.php
readOnly: true
subPath: config.kubernetes.php
- name: dagd-config
mountPath: /etc/php81/conf.d/50_dagd.ini
readOnly: true
subPath: php.ini
volumes:
- name: nginx-config
configMap:
name: nginx-config
- name: dagd-config
configMap:
name: dagd-config
---
apiVersion: v1
kind: Service
metadata:
name: dagd-app
spec:
ports:
- port: 80
targetPort: http
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment