templates/deployment.yaml を更新
This commit is contained in:
@@ -28,20 +28,19 @@ spec:
|
|||||||
echo "=== WordPress Initialization Started ==="
|
echo "=== WordPress Initialization Started ==="
|
||||||
|
|
||||||
echo "Copying WordPress to emptyDir..."
|
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
|
if [ ! -d /var/www/html/wp-content/themes ]; then
|
||||||
echo "Initializing wp-content..."
|
echo "Initializing wp-content in PVC..."
|
||||||
mkdir -p /bitnami/wordpress/wp-content
|
cp -rp /usr/src/wordpress/wp-content/* /var/www/html/wp-content/
|
||||||
cp -rp /usr/src/wordpress/wp-content/* /bitnami/wordpress/wp-content/
|
echo "wp-content initialized"
|
||||||
|
else
|
||||||
|
echo "wp-content already exists, preserving user data"
|
||||||
fi
|
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..."
|
echo "Generating wp-config.php..."
|
||||||
cat > /opt/bitnami/wordpress/wp-config.php << 'EOF'
|
cat > /var/www/html/wp-config.php << 'EOF'
|
||||||
<?php
|
<?php
|
||||||
define('DB_NAME', getenv('WORDPRESS_DB_NAME'));
|
define('DB_NAME', getenv('WORDPRESS_DB_NAME'));
|
||||||
define('DB_USER', getenv('WORDPRESS_DB_USER'));
|
define('DB_USER', getenv('WORDPRESS_DB_USER'));
|
||||||
@@ -122,7 +121,7 @@ spec:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Checking if WordPress is already installed..."
|
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
|
if [ -z "$TABLES" ]; then
|
||||||
echo "=== Starting WordPress Installation ==="
|
echo "=== Starting WordPress Installation ==="
|
||||||
@@ -130,13 +129,13 @@ spec:
|
|||||||
if [ -z "$WP_ADMIN_PASSWORD" ]; then
|
if [ -z "$WP_ADMIN_PASSWORD" ]; then
|
||||||
WP_ADMIN_PASSWORD=$(tr -dc 'A-Za-z0-9!@#$%^&*' < /dev/urandom | head -c 16)
|
WP_ADMIN_PASSWORD=$(tr -dc 'A-Za-z0-9!@#$%^&*' < /dev/urandom | head -c 16)
|
||||||
echo "Generated admin password: $WP_ADMIN_PASSWORD"
|
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
|
fi
|
||||||
|
|
||||||
INSTALL_URL="http://127.0.0.1"
|
INSTALL_URL="http://127.0.0.1"
|
||||||
|
|
||||||
echo "Installing WordPress..."
|
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" \
|
--url="$INSTALL_URL" \
|
||||||
--title="$WP_SITE_TITLE" \
|
--title="$WP_SITE_TITLE" \
|
||||||
--admin_user="$WP_ADMIN_USER" \
|
--admin_user="$WP_ADMIN_USER" \
|
||||||
@@ -146,8 +145,8 @@ spec:
|
|||||||
|
|
||||||
echo "=== WordPress Installation Completed ==="
|
echo "=== WordPress Installation Completed ==="
|
||||||
echo "Admin User: $WP_ADMIN_USER"
|
echo "Admin User: $WP_ADMIN_USER"
|
||||||
if [ -f /bitnami/wordpress/.initial-admin-password ]; then
|
if [ -f /var/www/html/wp-content/.initial-admin-password ]; then
|
||||||
echo "Admin Password: $(cat /bitnami/wordpress/.initial-admin-password)"
|
echo "Admin Password: $(cat /var/www/html/wp-content/.initial-admin-password)"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "WordPress is already installed, skipping installation"
|
echo "WordPress is already installed, skipping installation"
|
||||||
@@ -155,7 +154,7 @@ spec:
|
|||||||
|
|
||||||
{{- if .Values.wordpress.adsTxt.enabled }}
|
{{- if .Values.wordpress.adsTxt.enabled }}
|
||||||
echo "Deploying ads.txt..."
|
echo "Deploying ads.txt..."
|
||||||
cat > /opt/bitnami/wordpress/ads.txt << 'ADSTXT'
|
cat > /var/www/html/ads.txt << 'ADSTXT'
|
||||||
{{ .Values.wordpress.adsTxt.content }}
|
{{ .Values.wordpress.adsTxt.content }}
|
||||||
ADSTXT
|
ADSTXT
|
||||||
echo "ads.txt deployed"
|
echo "ads.txt deployed"
|
||||||
@@ -163,12 +162,10 @@ spec:
|
|||||||
|
|
||||||
echo "=== WordPress Initialization Completed ==="
|
echo "=== WordPress Initialization Completed ==="
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: empty-dir
|
|
||||||
mountPath: /opt/bitnami/wordpress
|
|
||||||
subPath: app-base-dir
|
|
||||||
- name: wordpress-data
|
- name: wordpress-data
|
||||||
mountPath: /bitnami/wordpress
|
mountPath: /var/www/html
|
||||||
subPath: wordpress
|
- name: wordpress-persistent
|
||||||
|
mountPath: /var/www/html/wp-content
|
||||||
env:
|
env:
|
||||||
- name: WORDPRESS_DB_HOST
|
- name: WORDPRESS_DB_HOST
|
||||||
value: {{ .Values.wordpress.dbHost | quote }}
|
value: {{ .Values.wordpress.dbHost | quote }}
|
||||||
@@ -246,12 +243,10 @@ spec:
|
|||||||
containerPort: 80
|
containerPort: 80
|
||||||
protocol: TCP
|
protocol: TCP
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: empty-dir
|
|
||||||
mountPath: /opt/bitnami/wordpress
|
|
||||||
subPath: app-base-dir
|
|
||||||
- name: wordpress-data
|
- name: wordpress-data
|
||||||
mountPath: /bitnami/wordpress
|
mountPath: /var/www/html
|
||||||
subPath: wordpress
|
- name: wordpress-persistent
|
||||||
|
mountPath: /var/www/html/wp-content
|
||||||
- name: nginx-config
|
- name: nginx-config
|
||||||
mountPath: /etc/nginx/conf.d/default.conf
|
mountPath: /etc/nginx/conf.d/default.conf
|
||||||
subPath: default.conf
|
subPath: default.conf
|
||||||
@@ -285,18 +280,16 @@ spec:
|
|||||||
- name: WORDPRESS_TABLE_PREFIX
|
- name: WORDPRESS_TABLE_PREFIX
|
||||||
value: {{ .Values.wordpress.tablePrefix | quote }}
|
value: {{ .Values.wordpress.tablePrefix | quote }}
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: empty-dir
|
|
||||||
mountPath: /opt/bitnami/wordpress
|
|
||||||
subPath: app-base-dir
|
|
||||||
- name: wordpress-data
|
- name: wordpress-data
|
||||||
mountPath: /bitnami/wordpress
|
mountPath: /var/www/html
|
||||||
subPath: wordpress
|
- name: wordpress-persistent
|
||||||
|
mountPath: /var/www/html/wp-content
|
||||||
resources:
|
resources:
|
||||||
{{- toYaml .Values.resources.wordpress | nindent 12 }}
|
{{- toYaml .Values.resources.wordpress | nindent 12 }}
|
||||||
volumes:
|
volumes:
|
||||||
- name: empty-dir
|
|
||||||
emptyDir: {}
|
|
||||||
- name: wordpress-data
|
- name: wordpress-data
|
||||||
|
emptyDir: {}
|
||||||
|
- name: wordpress-persistent
|
||||||
{{- if .Values.persistence.enabled }}
|
{{- if .Values.persistence.enabled }}
|
||||||
persistentVolumeClaim:
|
persistentVolumeClaim:
|
||||||
claimName: {{ include "wordpress-nginx.fullname" . }}-pvc
|
claimName: {{ include "wordpress-nginx.fullname" . }}-pvc
|
||||||
|
|||||||
Reference in New Issue
Block a user