From 52693e8f6eb8bd22e8319444b28912576d72e6ee Mon Sep 17 00:00:00 2001 From: pieter Date: Wed, 26 Nov 2025 02:14:37 +0000 Subject: [PATCH] =?UTF-8?q?templates/deployment.yaml=20=E3=82=92=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/deployment.yaml | 46 +++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/templates/deployment.yaml b/templates/deployment.yaml index 2f1e71e..526af51 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -27,6 +27,9 @@ spec: set -e echo "=== WordPress Initialization Started ===" + echo "Copying WordPress files to writable location..." + cp -rp /usr/src/wordpress/* /wordpress/ + if [ ! -d /var/www/html/wp-content ]; then echo "Initializing wp-content directory..." mkdir -p /var/www/html/wp-content @@ -36,8 +39,12 @@ spec: echo "wp-content already exists, preserving user data" fi + echo "Removing default wp-content and creating symlink..." + rm -rf /wordpress/wp-content + ln -sf /var/www/html/wp-content /wordpress/wp-content + echo "Generating wp-config.php..." - cat > /usr/src/wordpress/wp-config.php << 'EOF' + cat > /wordpress/wp-config.php << 'EOF' /dev/null || true chmod +x /tmp/wp-cli.phar @@ -140,7 +142,7 @@ spec: INSTALL_URL="http://127.0.0.1" echo "Installing WordPress..." - /tmp/wp-cli.phar --path=/usr/src/wordpress core install \ + /tmp/wp-cli.phar --path=/wordpress core install \ --url="$INSTALL_URL" \ --title="$WP_SITE_TITLE" \ --admin_user="$WP_ADMIN_USER" \ @@ -157,17 +159,17 @@ spec: else echo "WordPress is already installed, skipping installation" - if /tmp/wp-cli.phar --path=/usr/src/wordpress core version 2>/dev/null; then + if /tmp/wp-cli.phar --path=/wordpress core version 2>/dev/null; then CURRENT_VERSION=$(cat /usr/src/wordpress/wp-includes/version.php | grep "wp_version = " | cut -d "'" -f 2) echo "Checking for WordPress updates... Target version: $CURRENT_VERSION" - /tmp/wp-cli.phar --path=/usr/src/wordpress core update --version=$CURRENT_VERSION 2>/dev/null || true - /tmp/wp-cli.phar --path=/usr/src/wordpress core update-db 2>/dev/null || true + /tmp/wp-cli.phar --path=/wordpress core update --version=$CURRENT_VERSION 2>/dev/null || true + /tmp/wp-cli.phar --path=/wordpress core update-db 2>/dev/null || true fi fi {{- if .Values.wordpress.adsTxt.enabled }} echo "Deploying ads.txt..." - cat > /var/www/html/ads.txt << 'ADSTXT' + cat > /wordpress/ads.txt << 'ADSTXT' {{ .Values.wordpress.adsTxt.content }} ADSTXT echo "ads.txt deployed" @@ -175,6 +177,8 @@ spec: echo "=== WordPress Initialization Completed ===" volumeMounts: + - name: wordpress-core + mountPath: /wordpress - name: wordpress-persistent mountPath: /var/www/html env: @@ -254,12 +258,8 @@ spec: containerPort: 80 protocol: TCP volumeMounts: - - name: wordpress-persistent - mountPath: /usr/src/wordpress/wp-content - subPath: wp-content - - name: wordpress-persistent - mountPath: /usr/src/wordpress/wp-config.php - subPath: wp-config.php + - name: wordpress-core + mountPath: /wordpress - name: nginx-config mountPath: /etc/nginx/conf.d/default.conf subPath: default.conf @@ -293,15 +293,13 @@ spec: - name: WORDPRESS_TABLE_PREFIX value: {{ .Values.wordpress.tablePrefix | quote }} volumeMounts: - - name: wordpress-persistent - mountPath: /usr/src/wordpress/wp-content - subPath: wp-content - - name: wordpress-persistent - mountPath: /usr/src/wordpress/wp-config.php - subPath: wp-config.php + - name: wordpress-core + mountPath: /wordpress resources: {{- toYaml .Values.resources.wordpress | nindent 12 }} volumes: + - name: wordpress-core + emptyDir: {} - name: wordpress-persistent {{- if .Values.persistence.enabled }} persistentVolumeClaim: