diff --git a/Targets/Wordpress/docker-compose.yml b/Targets/Wordpress/docker-compose.yml index 73a75d6..3514c12 100644 --- a/Targets/Wordpress/docker-compose.yml +++ b/Targets/Wordpress/docker-compose.yml @@ -3,48 +3,32 @@ version: "3.3" services: wordpress_server: - #build: ./wordpress_server/ - image: wordpress + build: ./wordpress_server/ container_name: wordpress_server networks: - - net + - wordpress_net depends_on: - wordpress_data + command: bash -c 'if [ ! -s /var/www/html/wp-config.php ]; then /root/wp core download --allow-root; sleep 10; /root/wp config create --dbname=wordpress --dbuser=wordpress --dbpass=54y6RxN7GfC7aes3 --dbhost=wordpress_data --allow-root; sleep 3; /root/wp core install --url="http://localhost/" --title="wordpress" --admin_user="admin" --admin_password="54y6RxN7GfC7aes3" --admin_email="sentrifugo.container@gmail.com" --allow-root; /root/wp --allow-root rewrite structure "/%postname%" --hard --debug; /root/wp rewrite flush --hard --debug --allow-root; sed -i "s/<\/IfModule>/RewriteCond \%{HTTP:Authorization} \^\(\.\*\)\nRewriteRule \^\(\.\*\) - [E=HTTP_AUTHORIZATION:\%1]\n<\/IfModule>\nSetEnvIf Authorization "\(\.\*\)" HTTP_AUTHORIZATION=\$$1/" /var/www/html/.htaccess; /root/sed.sh; /root/wp plugin install jwt-authentication-for-wp-rest-api --activate --allow-root; /root/wp plugin install wp-rest-api-log --activate --allow-root; /root/wp plugin install shibboleth --activate --allow-root; fi; /usr/local/bin/startup.sh;' ports: - "80:80" devices: - "/dev/tty:/dev/tty" - links: - - "wordpress_data:wordpress_data" volumes: - - wordpress_server:/var/www/html + - wordpress_server:/var/www/html wordpress_data: build: ./wordpress_data/ container_name: wordpress_data networks: - - net + - wordpress_net volumes: - - wordpress_data:/var/lib/mysql - - wordpress_cli: - #image: wordpress:cli - build: ./wordpress_cli/ - links: - - "wordpress_server:wordpress_server" - user: xfs - command: bash -c 'if [ ! -s /var/www/html/wp-config.php ]; then sleep 10; wp config create --dbname=wordpress --dbuser=wordpress --dbpass=54y6RxN7GfC7aes3 --dbhost=wordpress_data; sleep 3; wp core install --url="http://localhost/" --title="wordpress" --admin_user="admin" --admin_password="54y6RxN7GfC7aes3" --admin_email="sentrifugo.container@gmail.com"; sed -i "s/<\/IfModule>/RewriteCond \%{HTTP:Authorization} \^\(\.\*\)\nRewriteRule \^\(\.\*\) - [E=HTTP_AUTHORIZATION:\%1]\n<\/IfModule>\nSetEnvIf Authorization "\(\.\*\)" HTTP_AUTHORIZATION=\$$1/" /var/www/html/.htaccess; /tmp/sed.sh; wp plugin install jwt-authentication-for-wp-rest-api --activate; fi' - container_name: wordpress_cli - networks: - - net - depends_on: - - wordpress_data - - wordpress_server - volumes: - - wordpress_server:/var/www/html + - wordpress_data:/var/lib/mysql + ports: + - 3306 networks: - net: + wordpress_net: driver: bridge volumes: diff --git a/Targets/Wordpress/readme.txt b/Targets/Wordpress/readme.txt index 593c9e4..c1edde0 100644 --- a/Targets/Wordpress/readme.txt +++ b/Targets/Wordpress/readme.txt @@ -13,4 +13,12 @@ # http://localhost/wp-admin with # admin/54y6RxN7GfC7aes3 - +# This is built on the tier/shibboleth_sp +# container, but in this standalone use +# case keys are created so Shibboleth +# is healthy, but it is otherwise not +# configured. Use cases with include +# an SP will require further configuration +# of the wordpress_server container. +# The shibboleth plugin is included +# in the wordpress install and is activated diff --git a/Targets/Wordpress/wordpress_cli/Dockerfile b/Targets/Wordpress/wordpress_cli/Dockerfile deleted file mode 100644 index 6a5554c..0000000 --- a/Targets/Wordpress/wordpress_cli/Dockerfile +++ /dev/null @@ -1,5 +0,0 @@ -from wordpress:cli -USER xfs -VOLUME /var/www/html -COPY sed.sh /tmp -#RUN chmod 777 /var/www/html/sed.sh diff --git a/Targets/Wordpress/wordpress_cli/wp-config.php b/Targets/Wordpress/wordpress_cli/wp-config.php deleted file mode 100644 index d2f18df..0000000 --- a/Targets/Wordpress/wordpress_cli/wp-config.php +++ /dev/null @@ -1,89 +0,0 @@ -|u>t[Cmv'); -define('LOGGED_IN_KEY', '-rlFxPNHu|?qMY.]9M8B|WwheVIBHqxP=fcd42P^C./e)v[87?>ma$KSK=zsBe+h'); -define('NONCE_KEY', '59vz[Q_#}~~TOZ|%7.rvj?[Hc3]}Q0,.kB(vcA.K4hn:W K*tpH_me{0G6P^qey('); -define('AUTH_SALT', 'Snd__*ZhB{ih~qs20iwU||0}B,*tvFY*1tzzOb~]D~y/Kk4R?]B90+(d< -{_Ax9*@uewcP!Sc2T@AWI`%]^=I>IZ`99;W:z4J>K'); -define('LOGGED_IN_SALT', 'u?KRIqFtiOoG/wg*}u3QEC.~S<3S|^<`zTH*Z%&pwiW[.~]k+*uE0[*-3O-t~9JOx=-Sb ,F!%1q{Q/=9)h;>nhN~d'); - -/**#@-*/ - -/** - * WordPress Database Table prefix. - * - * You can have multiple installations in one database if you give each - * a unique prefix. Only numbers, letters, and underscores please! - */ -$table_prefix = 'wp_'; - -/** - * For developers: WordPress debugging mode. - * - * Change this to true to enable the display of notices during development. - * It is strongly recommended that plugin and theme developers use WP_DEBUG - * in their development environments. - * - * For information on other constants that can be used for debugging, - * visit the Codex. - * - * @link https://codex.wordpress.org/Debugging_in_WordPress - */ -define('WP_DEBUG', false); - -/* That's all, stop editing! Happy blogging. */ - -/** Absolute path to the WordPress directory. */ -if ( !defined('ABSPATH') ) - define('ABSPATH', dirname(__FILE__) . '/'); - -/** Sets up WordPress vars and included files. */ -require_once(ABSPATH . 'wp-settings.php'); diff --git a/Targets/Wordpress/wordpress_data/Dockerfile b/Targets/Wordpress/wordpress_data/Dockerfile index 48d4f16..d8bc288 100644 --- a/Targets/Wordpress/wordpress_data/Dockerfile +++ b/Targets/Wordpress/wordpress_data/Dockerfile @@ -11,4 +11,5 @@ ENV MYSQL_PASSWORD=54y6RxN7GfC7aes3 #RUN tar zxf lib_mysqludf_amqp-2.0.0.tar.gz #WORKDIR /tmp/lib_mysqludf_amqp-2.0.0 #RUN ./configure && make && make install #mysql -u root --password=54y6RxN7GfC7aes3 < installdb.sql +RUN cat /etc/resolv.conf EXPOSE 3306 diff --git a/Targets/Wordpress/wordpress_server/Dockerfile b/Targets/Wordpress/wordpress_server/Dockerfile new file mode 100644 index 0000000..48ee787 --- /dev/null +++ b/Targets/Wordpress/wordpress_server/Dockerfile @@ -0,0 +1,45 @@ +FROM tier/shibboleth_sp:3.0.4_03122019 + +VOLUME /var/www/html + +RUN mkdir /opt/tier/.wp-cli +#COPY container_files/wordpress/000-default.conf /etc/apache2/sites-available/ +COPY container_files/wordpress/sed.sh /root +COPY container_files/wordpress/wp /root +COPY container_files/wordpress/config.yml /root/.wp-cli +COPY container_files/wordpress/wp-cli.yml /var/www/html + +RUN chmod +x /root/wp +RUN yum update -y +RUN yum install -y http://rpms.remirepo.net/enterprise/remi-release-7.rpm \ + && yum install yum-utils \ + && yum-config-manager --enable remi-php72 \ + && yum install -y php php-gd mariadb wget php-mysql postfix +RUN echo 'date.timezone="UTC"' >> /etc/php.ini +#RUN echo 'nameserver 127.0.0.11' > /etc/resolv.conf +RUN /etc/shibboleth/keygen.sh -o /etc/shibboleth/ -y 10 -n sp-encrypt -f \ + && /etc/shibboleth/keygen.sh -o /etc/shibboleth/ -y 10 -n sp-signing -f + +#RUN cd /root \ +# && wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar \ +# && chmod +x wp-cli.phar + +RUN cat /etc/resolv.conf +WORKDIR /var/www/html +#RUN /root/wp-cli.phar core download +# && sleep 3 \ +# && cat /etc/resolv.conf \ +# && cat /etc/hosts \ +# && /root/wp-cli.phar config create --dbname=wordpress --dbuser=wordpress --dbpass=54y6RxN7GfC7aes3 --dbhost=wordpress_data2 \ +# && sleep 15 \ +# && /root/wp-cli.phar core install --url="http://localhost/" --title="wordpress" --admin_user="admin" --admin_password="54y6RxN7GfC7aes3" --admin_email="sentrifugo.container@gmail.com" --allow-root \ +# && /root/wp-cli.phar plugin install jwt-authentication-for-wp-rest-api --activate --allow-root \ +# && /root/wp-cli.phar plugin install shibboleth --activate --allow-root \ +# && /root/wp-cli.phar plugin install wp-rest-api-log --activate --allow-root + +#RUN sed -i "s/<\/IfModule>/RewriteCond \%{HTTP:Authorization} \^\(\.\*\)\nRewriteRule \^\(\.\*\) - [E=HTTP_AUTHORIZATION:\%1]\n<\/IfModule>\nSetEnvIf Authorization "\(\.\*\)" HTTP_AUTHORIZATION=\$$1/" /var/www/html/.htaccess \ +# && sed -i "s/define( 'DB_COLLATE', '' );/define( 'DB_COLLATE', '' );\ndefine('JWT_AUTH_SECRET_KEY', 'your-top-secret-key');\ndefine('JWT_AUTH_CORS_ENABLE', true);\n/" /var/www/html/wp-config.php \ +# && sed -i "s/RewriteBase \//RewriteBase \/\nRewriteRule \^wp-json\/\(\.\*\) \/?rest_route=\/\$1 \[L\]\n/" /var/www/html/.htaccess + + +RUN chown -R apache:apache /var/www/html diff --git a/Targets/Wordpress/wordpress_server/container_files/wordpress/000-default.conf b/Targets/Wordpress/wordpress_server/container_files/wordpress/000-default.conf new file mode 100644 index 0000000..6d110b9 --- /dev/null +++ b/Targets/Wordpress/wordpress_server/container_files/wordpress/000-default.conf @@ -0,0 +1,32 @@ + + # The ServerName directive sets the request scheme, hostname and port that + # the server uses to identify itself. This is used when creating + # redirection URLs. In the context of virtual hosts, the ServerName + # specifies what hostname must appear in the request's Host: header to + # match this virtual host. For the default virtual host (this file) this + # value is not decisive as it is used as a last resort host regardless. + # However, you must set it for any further virtual host explicitly. + #ServerName www.example.com + + ServerAdmin webmaster@localhost + DocumentRoot /var/www/html + + # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, + # error, crit, alert, emerg. + # It is also possible to configure the loglevel for particular + # modules, e.g. + #LogLevel info ssl:warn + + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + + # For most configuration files from conf-available/, which are + # enabled or disabled at a global level, it is possible to + # include a line for only one particular virtual host. For example the + # following line enables the CGI configuration for this host only + # after it has been globally disabled with "a2disconf". + #Include conf-available/serve-cgi-bin.conf + HttpProtocolOptions Unsafe + + +# vim: syntax=apache ts=4 sw=4 sts=4 sr noet diff --git a/Targets/Wordpress/wordpress_server/container_files/wordpress/config.yml b/Targets/Wordpress/wordpress_server/container_files/wordpress/config.yml new file mode 100644 index 0000000..0e12e1c --- /dev/null +++ b/Targets/Wordpress/wordpress_server/container_files/wordpress/config.yml @@ -0,0 +1,3 @@ +apache_modules: + - mod_rewrite + diff --git a/Targets/Wordpress/wordpress_cli/sed.sh b/Targets/Wordpress/wordpress_server/container_files/wordpress/sed.sh similarity index 69% rename from Targets/Wordpress/wordpress_cli/sed.sh rename to Targets/Wordpress/wordpress_server/container_files/wordpress/sed.sh index 2592740..f10ddcf 100755 --- a/Targets/Wordpress/wordpress_cli/sed.sh +++ b/Targets/Wordpress/wordpress_server/container_files/wordpress/sed.sh @@ -3,4 +3,6 @@ #echo "define('JWT_AUTH_CORS_ENABLE', true);" >> /var/www/html/wp-config.php sed -i "s/define( 'DB_COLLATE', '' );/define( 'DB_COLLATE', '' );\ndefine('JWT_AUTH_SECRET_KEY', 'your-top-secret-key');\ndefine('JWT_AUTH_CORS_ENABLE', true);\n/" /var/www/html/wp-config.php sed -i "s/RewriteBase \//RewriteBase \/\nRewriteRule \^wp-json\/\(\.\*\) \/?rest_route=\/\$1 \[L\]\n/" /var/www/html/.htaccess +sed -i 's/RewriteRule \. \/index\.php \[L\]/RewriteCond %{REQUEST_URI} !\\\.sso\/\nRewriteRule \. \/index\.php \[L\]/' /var/www/html/.htaccess +sed -i 's/AllowOverride None/AllowOverride All/' /etc/httpd/conf/httpd.conf diff --git a/Targets/Wordpress/wordpress_server/container_files/wordpress/wp b/Targets/Wordpress/wordpress_server/container_files/wordpress/wp new file mode 100755 index 0000000..2884cb6 Binary files /dev/null and b/Targets/Wordpress/wordpress_server/container_files/wordpress/wp differ diff --git a/Targets/Wordpress/wordpress_server/container_files/wordpress/wp-cli.yml b/Targets/Wordpress/wordpress_server/container_files/wordpress/wp-cli.yml new file mode 100644 index 0000000..0e12e1c --- /dev/null +++ b/Targets/Wordpress/wordpress_server/container_files/wordpress/wp-cli.yml @@ -0,0 +1,3 @@ +apache_modules: + - mod_rewrite +