Sfoglia il codice sorgente

Move to new base image

Girish Ramakrishnan 10 anni fa
parent
commit
e8ac71b90b
8 ha cambiato i file con 94 aggiunte e 25 eliminazioni
  1. 19 9
      Dockerfile
  2. 4 0
      README.md
  3. 22 0
      apache2-wordpress.conf
  4. 0 9
      scripts/setup_app.sh
  5. 31 0
      start.sh
  6. 10 0
      supervisor-apache2.conf
  7. 4 3
      wordpress.app
  8. 4 4
      wp-config.php.template

+ 19 - 9
Dockerfile

@@ -1,21 +1,31 @@
-FROM girish/base:0.5
+FROM girish/base:0.10
 MAINTAINER Girish Ramakrishnan <girish@forwardbias.in>
 
 ENV DEBIAN_FRONTEND noninteractive
 
-RUN mkdir -p /app/code && cd /app/code \
-    && wget https://wordpress.org/latest.tar.gz \
-    && tar zxvf latest.tar.gz --strip-components=1 \
-    && rm latest.tar.gz \
-    && chown -R www-data.www-data /app/code
+RUN mkdir -p /app/code
+WORKDIR /app/code
+RUN curl -L http://wordpress.org/wordpress-4.1.tar.gz | tar -xz --strip-components 1 -f -
+RUN chown -R www-data.www-data /app/code
 
-ADD scripts/ /app/base/scripts/
+ADD start.sh /app/code/start.sh
+RUN chmod +x /app/code/start.sh
 
-ADD wp-config.php /app/configs/wp-config.php
+ADD wp-config.php.template /app/configs/wp-config.php.template
+
+# configure apache
+RUN rm /etc/apache2/sites-enabled/*
+RUN sed -i 's/upload_max_filesize = .*/upload_max_filesize = 8M/' /etc/php5/apache2/php.ini
+ADD apache2-wordpress.conf /etc/apache2/sites-available/wordpress.conf
+RUN ln -sf /etc/apache2/sites-available/wordpress.conf /etc/apache2/sites-enabled/wordpress.conf
+RUN a2enmod php5
+
+# supervisor
+ADD supervisor-apache2.conf /etc/supervisor/conf.d/apache2.conf
 
 # these links will become valid after setup is run
 RUN ln -s /app/data/wp-config.php /app/code/wp-config.php
 
 EXPOSE 80
 
-CMD [ "/app/base/scripts/start.sh", "--lamp" ]
+CMD [ "/app/code/start.sh" ]

+ 4 - 0
README.md

@@ -3,6 +3,10 @@ Building
 
 docker build -t girish/wordpress .
 
+Running
+=======
+docker run -tiP -e MYSQL_URL=<url> -v /tmp/data:/app/data girish/wordpress
+
 Notes
 =====
 The install step seems to install cookies! When testing using docker, make sure that the cookies of a previous install are cleared. Otherwise, one keeps getting a 304.

+ 22 - 0
apache2-wordpress.conf

@@ -0,0 +1,22 @@
+<VirtualHost *:80>
+    DocumentRoot /app/code
+
+    ErrorLog ${APACHE_LOG_DIR}/error.log
+    CustomLog ${APACHE_LOG_DIR}/access.log combined
+
+    <Directory /app/code/>
+        Options +FollowSymLinks
+        AllowOverride All
+        Require all granted
+    </Directory>
+
+    # some directories must be protected
+   <Directory /app/code/wp-content>
+        Options -FollowSymLinks
+        AllowOverride None
+        <IfModule mod_php5.c>
+            php_admin_flag engine off
+        </IfModule>
+    </Directory>
+</VirtualHost>
+

+ 0 - 9
scripts/setup_app.sh

@@ -1,9 +0,0 @@
-#!/bin/sh
-
-# create the database
-mysql -uroot -ppassword -e "CREATE DATABASE wordpress;"
-
-cp /app/configs/wp-config.php /app/data/wp-config.php
-mv /app/code/wp-content /app/data/wp-content/
-ln -s /app/data/wp-content /app/code/wp-content
-

+ 31 - 0
start.sh

@@ -0,0 +1,31 @@
+#!/bin/bash
+
+set -eux
+
+if [[ -z "$(ls -A /app/data)" ]]; then
+    cp /app/configs/wp-config.php.template /app/data/wp-config.php
+    mv /app/code/wp-content /app/data/wp-content/
+    ln -s /app/data/wp-content /app/code/wp-content
+fi
+
+: ${MYSQL_URL:=}
+if [[ -z "${MYSQL_URL}" ]]; then
+    echo "MYSQL_URL is empty"
+    exit 1
+fi
+
+proto="$(echo "${MYSQL_URL}" | sed -e's,^\(.*://\).*,\1,g')"
+url="$(echo ${MYSQL_URL/$proto/})"
+username="$(echo ${url} | cut -d: -f1)"
+password=$(echo ${url/$username:/} | cut -d@ -f1)
+host="$(echo ${url/$username:$password@/} | cut -d/ -f1)"
+db="$(echo ${url} | grep / | cut -d/ -f2-)"
+
+sed -e "s/define('DB_NAME',.*/define('DB_NAME', '${db}');/" \
+    -e "s/define('DB_USER',.*/define('DB_USER', '${username}');/" \
+    -e "s/define('DB_PASSWORD',.*/define('DB_PASSWORD', '${password}');/" \
+    -e "s/define('DB_HOST',.*/define('DB_HOST', '${host}');/" \
+    -i /app/data/wp-config.php
+
+/usr/bin/supervisord --configuration /etc/supervisor/supervisord.conf --nodaemon -i MediaWiki
+

+ 10 - 0
supervisor-apache2.conf

@@ -0,0 +1,10 @@
+[program:apache2]
+autorestart=true
+autostart=true
+command=/usr/bin/pidproxy /var/run/apache2/apache2.pid /bin/bash -c "source /etc/apache2/envvars && /usr/sbin/apache2 -DFOREGROUND"
+illasgroup=true
+priority=100
+stdout_logfile=/var/log/supervisor/%(program_name)s.log
+stderr_logfile=/var/log/supervisor/%(program_name)s.log
+stopasgroup=true
+

+ 4 - 3
wordpress.app

@@ -1,6 +1,7 @@
 {
-  "version": "0.4",
-  "dockerImage": "girish/wordpress:0.3",
+  "version": "0.5",
+  "dockerImage": "girish/wordpress:0.5",
   "healthCheckPath": "/",
-  "httpPort": "80"
+  "httpPort": "80",
+  "addons": [ "mysql" ]
 }

+ 4 - 4
wp-config.php → wp-config.php.template

@@ -16,16 +16,16 @@
 
 // ** MySQL settings - You can get this info from your web host ** //
 /** The name of the database for WordPress */
-define('DB_NAME', 'wordpress');
+define('DB_NAME', '');
 
 /** MySQL database username */
-define('DB_USER', 'root');
+define('DB_USER', '');
 
 /** MySQL database password */
-define('DB_PASSWORD', 'password');
+define('DB_PASSWORD', '');
 
 /** MySQL hostname */
-define('DB_HOST', 'localhost');
+define('DB_HOST', '');
 
 /** Database Charset to use in creating database tables. */
 define('DB_CHARSET', 'utf8');