templates/deployment.yaml を更新
This commit is contained in:
@@ -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'
|
||||
<?php
|
||||
define('DB_NAME', getenv('WORDPRESS_DB_NAME'));
|
||||
define('DB_USER', getenv('WORDPRESS_DB_USER'));
|
||||
@@ -122,7 +121,7 @@ spec:
|
||||
fi
|
||||
|
||||
echo "Checking if WordPress is already installed..."
|
||||
TABLES=$(/tmp/wp-cli.phar --path=/opt/bitnami/wordpress db query "SHOW TABLES LIKE '${WORDPRESS_TABLE_PREFIX}options';" 2>/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
|
||||
|
||||
Reference in New Issue
Block a user