Procházet zdrojové kódy

Make it work with readonly rootfs

Girish Ramakrishnan před 9 roky
rodič
revize
05ffe4d067
2 změnil soubory, kde provedl 12 přidání a 21 odebrání
  1. 8 5
      Dockerfile
  2. 4 16
      start.sh

+ 8 - 5
Dockerfile

@@ -4,19 +4,19 @@ MAINTAINER Girish Ramakrishnan <girish@cloudron.io>
 RUN mkdir -p /app/code
 WORKDIR /app/code
 RUN curl -L http://wordpress.org/wordpress-4.3.1.tar.gz | tar -xz --strip-components 1 -f -
-RUN chown -R www-data.www-data /app/code
+RUN mv /app/code/wp-content /app/code/wp-content-vanilla && ln -s /app/data/wp-content /app/code/wp-content
 
 ADD start.sh /app/code/start.sh
 
 RUN curl -o /app/code/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar 
 RUN chmod +x /app/code/wp
 
-RUN curl -L -o /app/code/wp-oauth.zip https://github.com//cloudron-io/WP-OAuth/archive/master.zip
-RUN ln -sf /app/data/wp-config.php /app/code/wp-config.php
-
-RUN curl -L -o /app/code/disable-wordpress-updates.zip https://downloads.wordpress.org/plugin/disable-wordpress-updates.zip
+# Get the plugins
+RUN curl -L -o /app/code/disable-wordpress-updates.zip https://downloads.wordpress.org/plugin/disable-wordpress-updates.1.4.7.zip
 RUN curl -L -o /app/code/wp-mail-smtp.zip https://downloads.wordpress.org/plugin/wp-mail-smtp.0.9.5.zip
 
+RUN chown -R www-data:www-data /app/code
+
 # configure apache
 RUN rm /etc/apache2/sites-enabled/*
 RUN sed -e 's,^ErrorLog.*,ErrorLog "|/bin/more",' -i /etc/apache2/apache2.conf
@@ -31,4 +31,7 @@ RUN sed -e 's/upload_max_filesize = .*/upload_max_filesize = 8M/' \
         -e 's,;session.save_path.*,session.save_path = "/run/mediawiki/sessions",' \
         -i /etc/php5/apache2/php.ini
 
+RUN mkdir /run/wordpress && \
+    ln -sf /run/wordpress/wp-config.php /app/code/wp-config.php
+
 CMD [ "/app/code/start.sh" ]

+ 4 - 16
start.sh

@@ -9,9 +9,8 @@ echo "Admin password is ${admin_password} and email is ${admin_email}"
 
 if [[ -z "$(ls -A /app/data)" ]]; then
     echo "Copying wp-content files on first run"
-    mv /app/code/wp-content /app/data/wp-content/
-    rm -rf /app/code/wp-content
-    ln -sf /app/data/wp-content /app/code/wp-content
+    mkdir /app/data/wp-content
+    cp -r /app/code/wp-content-vanilla/* /app/data/wp-content/
 
     # this also generates the salt in wp-config.php which must be backed up
     $WP core config --dbname="${MYSQL_DATABASE}" --dbuser="${MYSQL_USERNAME}" --dbpass="${MYSQL_PASSWORD}" --dbhost="${MYSQL_HOST}" --extra-php <<EOF
@@ -40,17 +39,9 @@ EOF
         --admin_password="${admin_password}" \
         --admin_email="${admin_email}"
 
-    echo "Installing OAuth plugin"
-    $WP plugin install --activate --force /app/code/wp-oauth.zip
-
     $WP plugin install --activate --force /app/code/disable-wordpress-updates.zip
     $WP plugin install --activate --force /app/code/wp-mail-smtp.zip
 
-    $WP option update users_can_register 1 # without this, nothing works
-    $WP option update wpoa_cloudron_api_enabled 1
-    $WP option update wpoa_new_user_role administrator # TODO: let the plugin determine this from the oauth profile
-    # $WP option update wpoa_hide_wordpress_login_form 1 # disabling this will make it impossible for users (commenters) to login
-    $WP option update wpoa_suppress_welcome_email 1
 else
     rm -rf /app/code/wp-content # upgrades & updates - starting out with existing data
     ln -sf /app/data/wp-content /app/code/wp-content
@@ -63,7 +54,7 @@ sed -e "s/define('DB_NAME',.*/define('DB_NAME', '${MYSQL_DATABASE}');/" \
     -e "s/define('DB_HOST',.*/define('DB_HOST', '${MYSQL_HOST}');/" \
     -e "s|define('WP_HOME',.*|define('WP_HOME', 'https://$(hostname -f)');|" \
     -e "s|define('WP_SITEURL',.*|define('WP_SITEURL', 'https://$(hostname -f)');|" \
-    -i /app/data/wp-config.php # sed -i seems to destroy symlink
+    -i /run/wordpress/wp-config.php # sed -i seems to destroy symlink
 
 # reset the admin password
 $WP user update $($WP user get admin --field=ID) --user_pass="${admin_password}"
@@ -77,10 +68,7 @@ $WP option update smtp_host ${MAIL_SMTP_SERVER}
 $WP option update smtp_port ${MAIL_SMTP_PORT}
 $WP option update smtp_auth false
 
-$WP option update wpoa_cloudron_api_id "${OAUTH_CLIENT_ID}"
-$WP option update wpoa_cloudron_api_secret "${OAUTH_CLIENT_SECRET}"
-
-chown -R www-data:www-data /app/code /app/data
+chown -R www-data:www-data /app/data
 
 echo "Starting apache"
 APACHE_CONFDIR="" source /etc/apache2/envvars