Files
ServerKit/backend/templates/wordpress-external-db.yaml

98 lines
2.8 KiB
YAML

id: wordpress-external-db
name: WordPress (External Database)
version: "7.1.3"
description: WordPress CMS connecting to an existing external MySQL database. Use this for dev/prod setups sharing the same database with different table prefixes.
icon: https://serverkit.ai/imgs/template-icons/wordpress-external-db.png
website: https://wordpress.org
documentation: https://wordpress.org/documentation/
categories:
- cms
- blog
- website
- development
variables:
- name: VERSION
description: WordPress image tag (WP core + PHP variant, e.g. 7.1.3-php8.3-apache)
type: string
default: "7.1.3-php8.3-apache"
hidden: true
- name: HTTP_PORT
description: HTTP port for WordPress
type: port
default: "8080"
hidden: true
- name: DB_HOST
description: External database host (e.g., 192.168.1.100 or db.example.com)
type: string
required: true
- name: DB_PORT
description: External database port
type: string
default: "3306"
- name: DB_NAME
description: Database name
type: string
default: "wordpress"
required: true
- name: DB_USER
description: Database username
type: string
default: "wordpress"
required: true
- name: DB_PASSWORD
description: Database password
type: password
required: true
- name: TABLE_PREFIX
description: WordPress table prefix (use different prefix for dev vs prod, e.g., wp_dev_)
type: string
default: "wp_"
ports:
- port: 8080
protocol: tcp
description: Web interface
volumes:
- name: html
path: /var/www/html
description: WordPress files
requirements:
memory: 512MB
storage: 2GB
compose:
services:
wordpress:
image: serverkit-wp-runtime:${APP_NAME}
build:
context: .
dockerfile: Dockerfile.serverkit-php
container_name: ${APP_NAME}
restart: unless-stopped
environment:
- WORDPRESS_DB_HOST=${DB_HOST}:${DB_PORT}
- WORDPRESS_DB_USER=${DB_USER}
- WORDPRESS_DB_PASSWORD=${DB_PASSWORD}
- WORDPRESS_DB_NAME=${DB_NAME}
- WORDPRESS_TABLE_PREFIX=${TABLE_PREFIX}
volumes:
- wordpress_html:/var/www/html
ports:
- "${HTTP_PORT}:80"
volumes:
wordpress_html:
files:
- path: Dockerfile.serverkit-php
content: |
FROM wordpress:${VERSION}
RUN php -r '$v=PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION; $min=["8.2"=>"8.2.35","8.3"=>"8.3.36"]; exit(isset($min[$v]) && version_compare(PHP_VERSION,$min[$v],">=") ? 0 : 1);' \
&& docker-php-ext-install pdo_mysql
RUN printf 'session.upload_progress.enabled=0\n' > /usr/local/etc/php/conf.d/zz-serverkit-security.ini \
&& printf 'php_admin_flag session.upload_progress.enabled Off\n' > /etc/apache2/conf-available/serverkit-php-security.conf \
&& a2enconf serverkit-php-security