From be997415f9ce50ea9e4d7d1bc8a71e2ffc506a1c Mon Sep 17 00:00:00 2001 From: pieter Date: Wed, 26 Nov 2025 07:32:11 +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 | 59 +++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 33 deletions(-) diff --git a/templates/deployment.yaml b/templates/deployment.yaml index f4d2c48..85b4984 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -28,20 +28,19 @@ spec: echo "=== WordPress Initialization Started ===" echo "Copying WordPress to emptyDir..." - cp -rp /usr/src/wordpress/* /opt/bitnami/wordpress/ + cp -rp /usr/src/wordpress/* /var/www/html/ + echo "WordPress files copied" - if [ ! -d /bitnami/wordpress/wp-content ]; then - echo "Initializing wp-content..." - mkdir -p /bitnami/wordpress/wp-content - cp -rp /usr/src/wordpress/wp-content/* /bitnami/wordpress/wp-content/ + if [ ! -d /var/www/html/wp-content/themes ]; then + echo "Initializing wp-content in PVC..." + cp -rp /usr/src/wordpress/wp-content/* /var/www/html/wp-content/ + echo "wp-content initialized" + else + echo "wp-content already exists, preserving user data" fi - echo "Removing default wp-content and linking to PVC..." - rm -rf /opt/bitnami/wordpress/wp-content - ln -sf /bitnami/wordpress/wp-content /opt/bitnami/wordpress/wp-content - echo "Generating wp-config.php..." - cat > /opt/bitnami/wordpress/wp-config.php << 'EOF' + cat > /var/www/html/wp-config.php << 'EOF' /dev/null || echo "") + TABLES=$(/tmp/wp-cli.phar --path=/var/www/html db query "SHOW TABLES LIKE '${WORDPRESS_TABLE_PREFIX}options';" 2>/dev/null || echo "") if [ -z "$TABLES" ]; then echo "=== Starting WordPress Installation ===" @@ -130,13 +129,13 @@ spec: if [ -z "$WP_ADMIN_PASSWORD" ]; then WP_ADMIN_PASSWORD=$(tr -dc 'A-Za-z0-9!@#$%^&*' < /dev/urandom | head -c 16) echo "Generated admin password: $WP_ADMIN_PASSWORD" - echo "$WP_ADMIN_PASSWORD" > /bitnami/wordpress/.initial-admin-password + echo "$WP_ADMIN_PASSWORD" > /var/www/html/wp-content/.initial-admin-password fi INSTALL_URL="http://127.0.0.1" echo "Installing WordPress..." - /tmp/wp-cli.phar --path=/opt/bitnami/wordpress core install \ + /tmp/wp-cli.phar --path=/var/www/html core install \ --url="$INSTALL_URL" \ --title="$WP_SITE_TITLE" \ --admin_user="$WP_ADMIN_USER" \ @@ -146,8 +145,8 @@ spec: echo "=== WordPress Installation Completed ===" echo "Admin User: $WP_ADMIN_USER" - if [ -f /bitnami/wordpress/.initial-admin-password ]; then - echo "Admin Password: $(cat /bitnami/wordpress/.initial-admin-password)" + if [ -f /var/www/html/wp-content/.initial-admin-password ]; then + echo "Admin Password: $(cat /var/www/html/wp-content/.initial-admin-password)" fi else echo "WordPress is already installed, skipping installation" @@ -155,7 +154,7 @@ spec: {{- if .Values.wordpress.adsTxt.enabled }} echo "Deploying ads.txt..." - cat > /opt/bitnami/wordpress/ads.txt << 'ADSTXT' + cat > /var/www/html/ads.txt << 'ADSTXT' {{ .Values.wordpress.adsTxt.content }} ADSTXT echo "ads.txt deployed" @@ -163,12 +162,10 @@ spec: echo "=== WordPress Initialization Completed ===" volumeMounts: - - name: empty-dir - mountPath: /opt/bitnami/wordpress - subPath: app-base-dir - name: wordpress-data - mountPath: /bitnami/wordpress - subPath: wordpress + mountPath: /var/www/html + - name: wordpress-persistent + mountPath: /var/www/html/wp-content env: - name: WORDPRESS_DB_HOST value: {{ .Values.wordpress.dbHost | quote }} @@ -246,12 +243,10 @@ spec: containerPort: 80 protocol: TCP volumeMounts: - - name: empty-dir - mountPath: /opt/bitnami/wordpress - subPath: app-base-dir - name: wordpress-data - mountPath: /bitnami/wordpress - subPath: wordpress + mountPath: /var/www/html + - name: wordpress-persistent + mountPath: /var/www/html/wp-content - name: nginx-config mountPath: /etc/nginx/conf.d/default.conf subPath: default.conf @@ -285,18 +280,16 @@ spec: - name: WORDPRESS_TABLE_PREFIX value: {{ .Values.wordpress.tablePrefix | quote }} volumeMounts: - - name: empty-dir - mountPath: /opt/bitnami/wordpress - subPath: app-base-dir - name: wordpress-data - mountPath: /bitnami/wordpress - subPath: wordpress + mountPath: /var/www/html + - name: wordpress-persistent + mountPath: /var/www/html/wp-content resources: {{- toYaml .Values.resources.wordpress | nindent 12 }} volumes: - - name: empty-dir - emptyDir: {} - name: wordpress-data + emptyDir: {} + - name: wordpress-persistent {{- if .Values.persistence.enabled }} persistentVolumeClaim: claimName: {{ include "wordpress-nginx.fullname" . }}-pvc