Skip to content
Snippets Groups Projects
Commit 3707e26a authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

Update all VM docker images to use supervisord and give the (default)...

Update all VM docker images to use supervisord and give the (default) possibility of using a local mysql daemon instead of a linked container
parent 8c5a1a35
No related branches found
No related tags found
No related merge requests found
...@@ -4,9 +4,10 @@ MAINTAINER Reinhold Kainhofer <reinhold@kainhofer.com> ...@@ -4,9 +4,10 @@ MAINTAINER Reinhold Kainhofer <reinhold@kainhofer.com>
# Enable Apache Rewrite Module # Enable Apache Rewrite Module
RUN a2enmod rewrite RUN a2enmod rewrite
RUN apt-get update
# Install PHP extensions # Install PHP extensions
RUN apt-get update && apt-get install -y libpng12-dev libjpeg-dev zip unzip && rm -rf /var/lib/apt/lists/* \ RUN apt-get install -y libpng12-dev libjpeg-dev zip unzip sudo \
&& docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \ && docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \
&& docker-php-ext-install gd && docker-php-ext-install gd
RUN docker-php-ext-install mysqli RUN docker-php-ext-install mysqli
...@@ -14,24 +15,37 @@ RUN docker-php-ext-install mysqli ...@@ -14,24 +15,37 @@ RUN docker-php-ext-install mysqli
VOLUME /var/www/html VOLUME /var/www/html
# Install MySQL (will only be started if needed) # Install MySQL (will only be started if needed)
# RUN apt-get update && apt-get install -y mysql-server && rm -rf /var/lib/apt/lists/* # RUN export DEBIAN_FRONTEND=noninteractive
RUN echo "mysql-server-5.5 mysql-server/root_password password root" | debconf-set-selections
RUN echo "mysql-server-5.5 mysql-server/root_password_again password root" | debconf-set-selections
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server
RUN apt-get install -y supervisor
# Define Joomla version and expected SHA1 signature # Define Joomla version and expected SHA1 signature
ENV VMFULL_VERSION 2.6.14 ENV VM_VERSION 2.6.14
ENV VMFULL_MD5 0a589d9db3831ae4e3d8eb95db28aeee ENV VM_DLDIR 880
ENV VM_MD5 0a589d9db3831ae4e3d8eb95db28aeee
ENV VM_POSTFIX ""
# Download package and extract to web volume # Download package and extract to web volume
RUN curl -o virtuemart.zip -SL http://dev.virtuemart.net/attachments/download/880/VirtueMart${VMFULL_VERSION}_Joomla_2.5.27-Stable-Full_Package.zip \ RUN curl -o virtuemart.zip -SL http://dev.virtuemart.net/attachments/download/${VM_DLDIR}/VirtueMart${VM_VERSION}_Joomla_2.5.27-Stable-Full_Package${VM_POSTFIX}.zip \
&& echo "$VMFULL_MD5 *virtuemart.zip" | md5sum -c - \ && echo "$VM_MD5 *virtuemart.zip" | md5sum -c - \
&& mkdir /usr/src/virtuemart \ && mkdir /usr/src/virtuemart \
&& unzip virtuemart.zip -d /usr/src/virtuemart \ && unzip virtuemart.zip -d /usr/src/virtuemart \
&& rm virtuemart.zip \ && rm virtuemart.zip \
&& chown -R www-data:www-data /usr/src/virtuemart && chown -R www-data:www-data /usr/src/virtuemart
# Clean up the apt cache etc.
RUN rm -rf /var/lib/apt/lists/*
# Copy init scripts and custom .htaccess # Copy init scripts and custom .htaccess
RUN echo "[program:mysql]\ncommand=/usr/bin/pidproxy /run/mysqld/mysqld.pid /usr/bin/mysqld_safe \nautorestart=true\n" > /etc/supervisor/conf.d/mysql.conf.save
COPY supervisord.conf /etc/supervisor/supervisord.conf
COPY docker-entrypoint.sh /entrypoint.sh COPY docker-entrypoint.sh /entrypoint.sh
COPY makedb.php /makedb.php COPY makedb.php /makedb.php
ENTRYPOINT ["/entrypoint.sh"] ENTRYPOINT ["/entrypoint.sh"]
CMD ["apache2-foreground"] CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]
...@@ -2,102 +2,133 @@ ...@@ -2,102 +2,133 @@
set -e set -e
if [[ "$1" == apache2* ]]; then if [[ ! -e "/etc/opentools-docker-configured" ]]; then
if [ -n "$MYSQL_PORT_3306_TCP" ]; then # This docker container has not been configured yet, use the env variables
if [ -z "$JOOMLA_DB_HOST" ]; then # to set up the MYSQL server or linked container
JOOMLA_DB_HOST='mysql'
else
echo >&2 "warning: both JOOMLA_DB_HOST and MYSQL_PORT_3306_TCP found"
echo >&2 " Connecting to JOOMLA_DB_HOST ($JOOMLA_DB_HOST)"
echo >&2 " instead of the linked mysql container"
fi
fi
# If the DB user is 'root' then use the MySQL root password env var # check if a MYSQL container is linked:
: ${JOOMLA_DB_USER:=root} if [ -n "$MYSQL_PORT_3306_TCP" ]; then
if [ "$JOOMLA_DB_USER" = 'root' ]; then if [ -z "$JOOMLA_DB_HOST" ]; then
: ${JOOMLA_DB_PASSWORD:=$MYSQL_ENV_MYSQL_ROOT_PASSWORD} JOOMLA_DB_HOST='mysql'
fi else
if [ -z "$JOOMLA_DB_HOST" ]; then echo >&2 "warning: both JOOMLA_DB_HOST and MYSQL_PORT_3306_TCP found"
echo >&2 "Neither linked database container nor mysql dabase server host given. " echo >&2 " Connecting to JOOMLA_DB_HOST ($JOOMLA_DB_HOST)"
echo >&2 " Assuming local installation. An instance of the MySQL server will be installed locally." echo >&2 " instead of the linked mysql container"
MYSQL_LOCAL=1 fi
JOOMLA_DB_HOST="127.0.0.1" fi
if [ -z "${JOOMLA_DB_PASSWORD}" ]; then
JOOMLA_DB_PASSWORD='root' # If the DB user is 'root' and no DB password is given, then use the MySQL root password env var
echo >&2 "No MySQL root password given. Assuming password 'root'." : ${JOOMLA_DB_USER:=root}
if [ "$JOOMLA_DB_USER" = 'root' ]; then
: ${JOOMLA_DB_PASSWORD:=$MYSQL_ENV_MYSQL_ROOT_PASSWORD}
fi
# Check for local MySQL installation:
if [ -z "$JOOMLA_DB_HOST" ]; then
# No linked container and no explicit DB host => local MySQL installation
echo >&2 "Neither linked database container nor mysql dabase server host given. "
echo >&2 " Assuming local installation. An instance of the MySQL server will be installed locally."
MYSQL_LOCAL=1
JOOMLA_DB_HOST="127.0.0.1"
if [ -z "${JOOMLA_DB_PASSWORD}" ]; then
JOOMLA_DB_PASSWORD='root'
echo >&2 "No MySQL root password given. Assuming password 'root'."
fi
echo >&2 " Root password is ${JOOMLA_DB_PASSWORD}."
# Temporarily start the mysql daemon to set up the database and shut it
# down again (supervisord will start it at the very end)
echo "Starting temporary local MySQL server to set up the database..."
/usr/bin/mysqld_safe > /dev/null 2>&1 &
timeout=30
echo -n "Waiting for database server to accept connections"
while ! /usr/bin/mysqladmin --user=root --password=root status > /dev/null 2>&1; do
timeout=$(($timeout-1))
if [ $timeout -eq 0 ]; then
echo -e "\n Unable to connecto the database server. Aborting..."
exit 1
fi fi
echo >&2 " Root password is ${JOOMLA_DB_PASSWORD}." echo -n "."
sleep 1
export DEBIAN_FRONTEND=noninteractive done
echo
mysqladmin --password=root password "${JOOMLA_DB_PASSWORD}"
# enable mysqld in the supervisor config
cp /etc/supervisor/conf.d/mysql.conf.save /etc/supervisor/conf.d/mysql.conf
fi
echo "mysql-server-5.5 mysql-server/root_password password ${JOOMLA_DB_PASSWORD}" | debconf-set-selections
echo "mysql-server-5.5 mysql-server/root_password_again password ${JOOMLA_DB_PASSWORD}" | debconf-set-selections # Now set up the Database for Joomla/VirtueMart:
# echo 'phpmyadmin phpmyadmin/dbconfig-install boolean true' | debconf-set-selections : ${JOOMLA_DB_NAME:=virtuemart}
# echo 'phpmyadmin phpmyadmin/app-password-confirm password ${JOOMLA_DB_PASSWORD}' | debconf-set-selections
# echo 'phpmyadmin phpmyadmin/mysql/admin-pass password ${JOOMLA_DB_PASSWORD}' | debconf-set-selections
# echo 'phpmyadmin phpmyadmin/mysql/app-pass password ${JOOMLA_DB_PASSWORD}' | debconf-set-selections
# echo 'phpmyadmin phpmyadmin/reconfigure-webserver multiselect apache2' | debconf-set-selections
dpkg -s mysql-server > /dev/null 2>&1 || ( apt-get -q update && apt-get -y -q install mysql-server && rm -rf /var/lib/apt/lists/* ) if [ -z "$JOOMLA_DB_PASSWORD" ]; then
# echo >&2 "error: missing JOOMLA_DB_HOST and MYSQL_PORT_3306_TCP environment variables" echo >&2 "error: missing required JOOMLA_DB_PASSWORD environment variable"
# echo >&2 " Did you forget to --link some_mysql_container:mysql or set an external db" echo >&2 " Did you forget to -e JOOMLA_DB_PASSWORD=... or link to a container?"
# echo >&2 " with -e JOOMLA_DB_HOST=hostname:port?" echo >&2
# exit 1 echo >&2 " (Also of interest might be JOOMLA_DB_USER and JOOMLA_DB_NAME.)"
fi exit 1
if [ -n "$MYSQL_LOCAL" ]; then fi
echo >&2 "Starting MySQL daemon..." # Ensure the MySQL Database is created
service mysql restart php /makedb.php "$JOOMLA_DB_HOST" "$JOOMLA_DB_USER" "$JOOMLA_DB_PASSWORD" "$JOOMLA_DB_NAME"
fi
: ${JOOMLA_DB_NAME:=j2vm2
if [ -z "$JOOMLA_DB_PASSWORD" ]; then # Now set up the Joomla/VirtueMart installation files in apache's directory:
echo >&2 "error: missing required JOOMLA_DB_PASSWORD environment variable" if ! [ -e index.php -a -e libraries/cms/version/version.php ]; then
echo >&2 " Did you forget to -e JOOMLA_DB_PASSWORD=... ?" echo >&2 "Virtuemart/Joomla not found in $(pwd) - copying now..."
echo >&2
echo >&2 " (Also of interest might be JOOMLA_DB_USER and JOOMLA_DB_NAME.)"
exit 1
fi
if ! [ -e index.php -a -e libraries/cms/version/version.php ]; then if [ "$(ls -A)" ]; then
echo >&2 "Virtuemart/Joomla not found in $(pwd) - copying now..." echo >&2 "WARNING: $(pwd) is not empty - press Ctrl+C now if this is an error!"
( set -x; ls -A; sleep 10 )
fi
if [ "$(ls -A)" ]; then tar cf - --one-file-system -C /usr/src/virtuemart . | tar xf -
echo >&2 "WARNING: $(pwd) is not empty - press Ctrl+C now if this is an error!"
( set -x; ls -A; sleep 10 ) # Some versions of the full installer hae an additional subdir in the ZIP file.
fi # Search for joomla.xml and mv everything from that directory to the webroot
if [ ! -e joomla.xml ]; then
for jmanifest in */joomla.xml; do
jdir=$(dirname $jmanifest)
echo
mv $jdir/** .
rm -rf $jdir
done
fi
tar cf - --one-file-system -C /usr/src/virtuemart . | tar xf - if [ -e htaccess.txt -a ! -e .htaccess ]; then
# NOTE: The "Indexes" option is disabled in the php:apache base image so remove it as we enable .htaccess
sed -r 's/^(Options -Indexes.*)$/#\1/' htaccess.txt > .htaccess
chown www-data:www-data .htaccess
fi
if [ ! -e .htaccess ]; then sed 's/default="localhost"/default="'$JOOMLA_DB_HOST'"/;
# NOTE: The "Indexes" option is disabled in the php:apache base image so remove it as we enable .htaccess s/\(db_user.*\)$/\1 default="'$JOOMLA_DB_USER'"/;
sed -r 's/^(Options -Indexes.*)$/#\1/' htaccess.txt > .htaccess s/\(db_pass.*\)$/\1 default="'$JOOMLA_DB_PASSWORD'"/;
chown www-data:www-data .htaccess s/\(db_name.*\)$/\1 default="'$JOOMLA_DB_NAME'"/' installation/models/forms/database.xml > installation/models/forms/database.xml.new
fi mv installation/models/forms/database.xml.new installation/models/forms/database.xml
sed 's/default="localhost"/default="'$JOOMLA_DB_HOST'"/;
s/\(db_user.*\)$/\1 default="'$JOOMLA_DB_USER'"/;
s/\(db_pass.*\)$/\1 default="'$JOOMLA_DB_PASSWORD'"/;
s/\(db_name.*\)$/\1 default="'$JOOMLA_DB_NAME'"/' installation/models/forms/database.xml > installation/models/forms/database.xml.new
mv installation/models/forms/database.xml.new installation/models/forms/database.xml
echo >&2 "Complete! Virtuemart has been successfully copied to $(pwd)" echo >&2 "Complete! Virtuemart has been successfully copied to $(pwd)"
fi fi
# Ensure the MySQL Database is created if [ "$MYSQL_LOCAL" = "1" ]; then
php /makedb.php "$JOOMLA_DB_HOST" "$JOOMLA_DB_USER" "$JOOMLA_DB_PASSWORD" "$JOOMLA_DB_NAME" # Local installation, so shut down MySQL again, will later be started through supervisord
echo "Shutting down temporary MySQL instance ..."
/usr/bin/mysqladmin --user=root --password="${JOOMLA_DB_PASSWORD}" shutdown
fi
echo >&2 "========================================================================" echo >&2 "========================================================================"
echo >&2 echo >&2
echo >&2 "This server is now configured to run Joomla!" echo >&2 "This server is now configured to run Joomla!"
echo >&2 "You will need the following database information to install Joomla:" echo >&2 "You will need the following database information to install Joomla:"
echo >&2 "Host Name: $JOOMLA_DB_HOST" echo >&2 "Host Name: $JOOMLA_DB_HOST"
echo >&2 "Database Name: $JOOMLA_DB_NAME" echo >&2 "Database Name: $JOOMLA_DB_NAME"
echo >&2 "Database Username: $JOOMLA_DB_USER" echo >&2 "Database Username: $JOOMLA_DB_USER"
echo >&2 "Database Password: $JOOMLA_DB_PASSWORD" echo >&2 "Database Password: $JOOMLA_DB_PASSWORD"
echo >&2 echo >&2
echo >&2 "========================================================================" echo >&2 "========================================================================"
# create the file to indicate this container has been configured:
touch /etc/opentools-docker-configured
fi fi
exec "$@" exec "$@"
[supervisord]
nodaemon=true
[program:apache]
command=/usr/local/bin/apache2-foreground
autorestart=true
[include]
files = /etc/supervisor/conf.d/*.conf
...@@ -4,10 +4,10 @@ MAINTAINER Reinhold Kainhofer <reinhold@kainhofer.com> ...@@ -4,10 +4,10 @@ MAINTAINER Reinhold Kainhofer <reinhold@kainhofer.com>
# Enable Apache Rewrite Module # Enable Apache Rewrite Module
RUN a2enmod rewrite RUN a2enmod rewrite
RUN apt-get update RUN apt-get update
# Install PHP extensions # Install PHP extensions
RUN apt-get install -y libpng12-dev libjpeg-dev zip unzip \ RUN apt-get install -y libpng12-dev libjpeg-dev zip unzip sudo \
&& docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \ && docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \
&& docker-php-ext-install gd && docker-php-ext-install gd
RUN docker-php-ext-install mysqli RUN docker-php-ext-install mysqli
...@@ -24,28 +24,28 @@ RUN apt-get install -y supervisor ...@@ -24,28 +24,28 @@ RUN apt-get install -y supervisor
# Define Joomla version and expected SHA1 signature # Define Joomla version and expected SHA1 signature
ENV VMFULL_VERSION 3.0.12 ENV VM_VERSION 3.0.12
ENV VMFULL_MD5 68dfeda59610bd798c0f03a7fb9340df ENV VM_DLDIR 983
ENV VMFULL_POSTFIX "_with_security_patch" ENV VM_MD5 68dfeda59610bd798c0f03a7fb9340df
ENV VM_POSTFIX "_with_security_patch"
# Download package and extract to web volume # Download package and extract to web volume
RUN curl -o virtuemart.zip -SL http://dev.virtuemart.net/attachments/download/983/VirtueMart${VMFULL_VERSION}_Joomla_2.5.29-Stable-Full_Package${VMFULL_POSTFIX}.zip \ RUN curl -o virtuemart.zip -SL http://dev.virtuemart.net/attachments/download/${VM_DLDIR}/VirtueMart${VM_VERSION}_Joomla_2.5.29-Stable-Full_Package${VM_POSTFIX}.zip \
&& echo "$VMFULL_MD5 *virtuemart.zip" | md5sum -c - \ && echo "$VM_MD5 *virtuemart.zip" | md5sum -c - \
&& mkdir /usr/src/virtuemart \ && mkdir /usr/src/virtuemart \
&& unzip virtuemart.zip -d /usr/src/virtuemart \ && unzip virtuemart.zip -d /usr/src/virtuemart \
&& rm virtuemart.zip \ && rm virtuemart.zip \
&& chown -R www-data:www-data /usr/src/virtuemart && chown -R www-data:www-data /usr/src/virtuemart
RUN echo "[program:mysql]\ncommand=/usr/bin/pidproxy /run/mysqld/mysqld.pid /usr/bin/mysqld_safe \nautorestart=true\n" > /etc/supervisor/conf.d/mysql.conf.save
# Clean up the apt cache etc. # Clean up the apt cache etc.
RUN rm -rf /var/lib/apt/lists/* RUN rm -rf /var/lib/apt/lists/*
# Copy init scripts and custom .htaccess # Copy init scripts and custom .htaccess
RUN echo "[program:mysql]\ncommand=/usr/bin/pidproxy /run/mysqld/mysqld.pid /usr/bin/mysqld_safe \nautorestart=true\n" > /etc/supervisor/conf.d/mysql.conf.save
COPY supervisord.conf /etc/supervisor/supervisord.conf
COPY docker-entrypoint.sh /entrypoint.sh COPY docker-entrypoint.sh /entrypoint.sh
COPY makedb.php /makedb.php COPY makedb.php /makedb.php
ADD supervisord.conf /etc/supervisor/supervisord.conf
ENTRYPOINT ["/entrypoint.sh"] ENTRYPOINT ["/entrypoint.sh"]
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"] CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]
...@@ -38,7 +38,7 @@ if [[ ! -e "/etc/opentools-docker-configured" ]]; then ...@@ -38,7 +38,7 @@ if [[ ! -e "/etc/opentools-docker-configured" ]]; then
# Temporarily start the mysql daemon to set up the database and shut it # Temporarily start the mysql daemon to set up the database and shut it
# down again (supervisord will start it at the very end) # down again (supervisord will start it at the very end)
echo "Starting local mysql server temporarily to set up the database..." echo "Starting temporary local MySQL server to set up the database..."
/usr/bin/mysqld_safe > /dev/null 2>&1 & /usr/bin/mysqld_safe > /dev/null 2>&1 &
timeout=30 timeout=30
echo -n "Waiting for database server to accept connections" echo -n "Waiting for database server to accept connections"
...@@ -71,11 +71,6 @@ if [[ ! -e "/etc/opentools-docker-configured" ]]; then ...@@ -71,11 +71,6 @@ if [[ ! -e "/etc/opentools-docker-configured" ]]; then
fi fi
# Ensure the MySQL Database is created # Ensure the MySQL Database is created
php /makedb.php "$JOOMLA_DB_HOST" "$JOOMLA_DB_USER" "$JOOMLA_DB_PASSWORD" "$JOOMLA_DB_NAME" php /makedb.php "$JOOMLA_DB_HOST" "$JOOMLA_DB_USER" "$JOOMLA_DB_PASSWORD" "$JOOMLA_DB_NAME"
if [ "$MYSQL_LOCAL" = "1" ]; then
# Local installation, so shut down MySQL again, will later be started through supervisord
/usr/bin/mysqladmin --user=root --password="${JOOMLA_DB_PASSWORD}" shutdown
fi
# Now set up the Joomla/VirtueMart installation files in apache's directory: # Now set up the Joomla/VirtueMart installation files in apache's directory:
...@@ -115,6 +110,12 @@ if [[ ! -e "/etc/opentools-docker-configured" ]]; then ...@@ -115,6 +110,12 @@ if [[ ! -e "/etc/opentools-docker-configured" ]]; then
echo >&2 "Complete! Virtuemart has been successfully copied to $(pwd)" echo >&2 "Complete! Virtuemart has been successfully copied to $(pwd)"
fi fi
if [ "$MYSQL_LOCAL" = "1" ]; then
# Local installation, so shut down MySQL again, will later be started through supervisord
echo "Shutting down temporary MySQL instance ..."
/usr/bin/mysqladmin --user=root --password="${JOOMLA_DB_PASSWORD}" shutdown
fi
echo >&2 "========================================================================" echo >&2 "========================================================================"
echo >&2 echo >&2
echo >&2 "This server is now configured to run Joomla!" echo >&2 "This server is now configured to run Joomla!"
......
...@@ -4,20 +4,32 @@ MAINTAINER Reinhold Kainhofer <reinhold@kainhofer.com> ...@@ -4,20 +4,32 @@ MAINTAINER Reinhold Kainhofer <reinhold@kainhofer.com>
# Enable Apache Rewrite Module # Enable Apache Rewrite Module
RUN a2enmod rewrite RUN a2enmod rewrite
RUN apt-get update
# Install PHP extensions # Install PHP extensions
RUN apt-get update && apt-get install -y libpng12-dev libjpeg-dev zip unzip sudo && rm -rf /var/lib/apt/lists/* \ RUN apt-get install -y libpng12-dev libjpeg-dev zip unzip sudo \
&& docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \ && docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \
&& docker-php-ext-install gd && docker-php-ext-install gd
RUN docker-php-ext-install mysqli RUN docker-php-ext-install mysqli
VOLUME /var/www/html VOLUME /var/www/html
# Install MySQL (will only be started if needed)
# RUN export DEBIAN_FRONTEND=noninteractive
RUN echo "mysql-server-5.5 mysql-server/root_password password root" | debconf-set-selections
RUN echo "mysql-server-5.5 mysql-server/root_password_again password root" | debconf-set-selections
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server
RUN apt-get install -y supervisor
# Define Joomla version and expected SHA1 signature # Define Joomla version and expected SHA1 signature
ENV VM_VERSION 3.0.10 ENV VM_VERSION 3.0.12
ENV VM_MD5 a684928d8b1e2dde0c9ac8e047d65038 ENV VM_DLDIR 979
ENV VM_MD5 2b9855cd0de8e7073fb3c4c7d633c5a3
# Download package and extract to web volume # Download package and extract to web volume
RUN curl -o virtuemart.zip -SL http://dev.virtuemart.net/attachments/download/972/com_virtuemart.${VM_VERSION}_extract_first.zip \ RUN curl -o virtuemart.zip -SL http://dev.virtuemart.net/attachments/download/${VM_DLDIR}/com_virtuemart.${VM_VERSION}_extract_first.zip \
&& echo "$VM_MD5 *virtuemart.zip" | md5sum -c - \ && echo "$VM_MD5 *virtuemart.zip" | md5sum -c - \
&& mkdir /usr/src/virtuemart \ && mkdir /usr/src/virtuemart \
&& unzip virtuemart.zip -d /usr/src/virtuemart \ && unzip virtuemart.zip -d /usr/src/virtuemart \
...@@ -26,11 +38,16 @@ RUN curl -o virtuemart.zip -SL http://dev.virtuemart.net/attachments/download/97 ...@@ -26,11 +38,16 @@ RUN curl -o virtuemart.zip -SL http://dev.virtuemart.net/attachments/download/97
&& unzip /usr/src/virtuemart/com_virtuemart*_ext_aio.zip -d /usr/src/virtuemart/com_virtumart_ext_aio/ \ && unzip /usr/src/virtuemart/com_virtuemart*_ext_aio.zip -d /usr/src/virtuemart/com_virtumart_ext_aio/ \
&& rm /usr/src/virtuemart/com_virtuemart*_ext_aio.zip && rm /usr/src/virtuemart/com_virtuemart*_ext_aio.zip
# Clean up the apt cache etc.
RUN rm -rf /var/lib/apt/lists/*
# Copy init scripts and custom .htaccess # Copy init scripts and custom .htaccess
RUN echo "[program:mysql]\ncommand=/usr/bin/pidproxy /run/mysqld/mysqld.pid /usr/bin/mysqld_safe \nautorestart=true\n" > /etc/supervisor/conf.d/mysql.conf.save
COPY supervisord.conf /etc/supervisor/supervisord.conf
COPY docker-entrypoint.sh /entrypoint.sh COPY docker-entrypoint.sh /entrypoint.sh
COPY makedb.php /makedb.php COPY makedb.php /makedb.php
COPY install-joomla.php /usr/src/joomla/installation/install.php COPY install-joomla.php /usr/src/joomla/installation/install.php
COPY install-joomla-extension.php /usr/src/joomla/cli/install-joomla-extension.php COPY install-joomla-extension.php /usr/src/joomla/cli/install-joomla-extension.php
ENTRYPOINT ["/entrypoint.sh"] ENTRYPOINT ["/entrypoint.sh"]
CMD ["apache2-foreground"] CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]
...@@ -2,92 +2,140 @@ ...@@ -2,92 +2,140 @@
set -e set -e
if [[ "$1" == apache2* ]]; then if [[ ! -e "/etc/opentools-docker-configured" ]]; then
if [ -n "$MYSQL_PORT_3306_TCP" ]; then # This docker container has not been configured yet, use the env variables
if [ -z "$JOOMLA_DB_HOST" ]; then # to set up the MYSQL server or linked container
JOOMLA_DB_HOST='mysql'
else # check if a MYSQL container is linked:
echo >&2 "warning: both JOOMLA_DB_HOST and MYSQL_PORT_3306_TCP found" if [ -n "$MYSQL_PORT_3306_TCP" ]; then
echo >&2 " Connecting to JOOMLA_DB_HOST ($JOOMLA_DB_HOST)" if [ -z "$JOOMLA_DB_HOST" ]; then
echo >&2 " instead of the linked mysql container" JOOMLA_DB_HOST='mysql'
fi else
fi echo >&2 "warning: both JOOMLA_DB_HOST and MYSQL_PORT_3306_TCP found"
echo >&2 " Connecting to JOOMLA_DB_HOST ($JOOMLA_DB_HOST)"
if [ -z "$JOOMLA_DB_HOST" ]; then echo >&2 " instead of the linked mysql container"
echo >&2 "error: missing JOOMLA_DB_HOST and MYSQL_PORT_3306_TCP environment variables" fi
echo >&2 " Did you forget to --link some_mysql_container:mysql or set an external db" fi
echo >&2 " with -e JOOMLA_DB_HOST=hostname:port?"
exit 1 # If the DB user is 'root' and no DB password is given, then use the MySQL root password env var
fi : ${JOOMLA_DB_USER:=root}
if [ "$JOOMLA_DB_USER" = 'root' ]; then
# If the DB user is 'root' then use the MySQL root password env var : ${JOOMLA_DB_PASSWORD:=$MYSQL_ENV_MYSQL_ROOT_PASSWORD}
: ${JOOMLA_DB_USER:=root} fi
if [ "$JOOMLA_DB_USER" = 'root' ]; then
: ${JOOMLA_DB_PASSWORD:=$MYSQL_ENV_MYSQL_ROOT_PASSWORD} # Check for local MySQL installation:
fi if [ -z "$JOOMLA_DB_HOST" ]; then
: ${JOOMLA_DB_NAME:=virtuemart} # No linked container and no explicit DB host => local MySQL installation
echo >&2 "Neither linked database container nor mysql dabase server host given. "
if [ -z "$JOOMLA_DB_PASSWORD" ]; then echo >&2 " Assuming local installation. An instance of the MySQL server will be installed locally."
echo >&2 "error: missing required JOOMLA_DB_PASSWORD environment variable" MYSQL_LOCAL=1
echo >&2 " Did you forget to -e JOOMLA_DB_PASSWORD=... ?" JOOMLA_DB_HOST="127.0.0.1"
echo >&2 if [ -z "${JOOMLA_DB_PASSWORD}" ]; then
echo >&2 " (Also of interest might be JOOMLA_DB_USER and JOOMLA_DB_NAME.)" JOOMLA_DB_PASSWORD='root'
exit 1 echo >&2 "No MySQL root password given. Assuming password 'root'."
fi fi
echo >&2 " Root password is ${JOOMLA_DB_PASSWORD}."
if ! [ -e index.php -a -e libraries/cms/version/version.php ]; then
echo >&2 "Joomla not found in $(pwd) - copying now..." # Temporarily start the mysql daemon to set up the database and shut it
# down again (supervisord will start it at the very end)
if [ "$(ls -A)" ]; then echo "Starting local mysql server temporarily to set up the database..."
echo >&2 "WARNING: $(pwd) is not empty - press Ctrl+C now if this is an error!" /usr/bin/mysqld_safe > /dev/null 2>&1 &
( set -x; ls -A; sleep 10 ) timeout=30
fi echo -n "Waiting for database server to accept connections"
while ! /usr/bin/mysqladmin --user=root --password=root status > /dev/null 2>&1; do
tar cf - --one-file-system -C /usr/src/joomla . | tar xf - timeout=$(($timeout-1))
if [ $timeout -eq 0 ]; then
if [ ! -e .htaccess ]; then echo -e "\n Unable to connecto the database server. Aborting..."
# NOTE: The "Indexes" option is disabled in the php:apache base image so remove it as we enable .htaccess exit 1
sed -r 's/^(Options -Indexes.*)$/#\1/' htaccess.txt > .htaccess fi
chown www-data:www-data .htaccess echo -n "."
fi sleep 1
done
echo >&2 "Complete! Joomla has been successfully copied to $(pwd)" echo
fi mysqladmin --password=root password "${JOOMLA_DB_PASSWORD}"
# Ensure the MySQL Database is created # enable mysqld in the supervisor config
php /makedb.php "$JOOMLA_DB_HOST" "$JOOMLA_DB_USER" "$JOOMLA_DB_PASSWORD" "$JOOMLA_DB_NAME" cp /etc/supervisor/conf.d/mysql.conf.save /etc/supervisor/conf.d/mysql.conf
fi
echo >&2 "========================================================================"
echo >&2
echo >&2 "This server is now configured to run Joomla!" # Now set up the Database for Joomla/VirtueMart:
echo >&2 "You will need the following database information to install Joomla:" : ${JOOMLA_DB_NAME:=virtuemart}
echo >&2 "Host Name: $JOOMLA_DB_HOST"
echo >&2 "Database Name: $JOOMLA_DB_NAME" if [ -z "$JOOMLA_DB_PASSWORD" ]; then
echo >&2 "Database Username: $JOOMLA_DB_USER" echo >&2 "error: missing required JOOMLA_DB_PASSWORD environment variable"
echo >&2 "Database Password: $JOOMLA_DB_PASSWORD" echo >&2 " Did you forget to -e JOOMLA_DB_PASSWORD=... or link to a container?"
echo >&2 echo >&2
echo >&2 "========================================================================" echo >&2 " (Also of interest might be JOOMLA_DB_USER and JOOMLA_DB_NAME.)"
exit 1
fi
# Now run the joomla Installer: # Ensure the MySQL Database is created
php /makedb.php "$JOOMLA_DB_HOST" "$JOOMLA_DB_USER" "$JOOMLA_DB_PASSWORD" "$JOOMLA_DB_NAME"
: ${JOOMLA_ADMIN_USER:=admin}
: ${JOOMLA_ADMIN_PASSWORD:=admin}
: ${JOOMLA_ADMIN_EMAIL:=admin@example.com} # Now set up the Joomla/VirtueMart installation files in apache's directory:
: ${JOOMLA_SITE_NAME:=Joomla Installation} if ! [ -e index.php -a -e libraries/cms/version/version.php ]; then
if [ -z "$JOOMLA_DB_PREFIX" ]; then echo >&2 "Joomla not found in $(pwd) - copying now..."
DBPREFIX="--dbprefix=\"${JOOMLA_DB_PREFIX}_\""
fi if [ "$(ls -A)" ]; then
echo >&2 "WARNING: $(pwd) is not empty - press Ctrl+C now if this is an error!"
php ./installation/install.php --name "$JOOMLA_SITE_NAME" \ ( set -x; ls -A; sleep 10 )
--admin-user "$JOOMLA_ADMIN_USER" --admin-pass "$JOOMLA_ADMIN_PASSWORD" --admin-email "$JOOMLA_ADMIN_EMAIL" \ fi
--db-host "$JOOMLA_DB_HOST" --db-user "$JOOMLA_DB_USER" --db-pass "$JOOMLA_DB_PASSWORD" --db-name "$JOOMLA_DB_NAME" $DBPREFIX && \
rm -rf "./installation/" # extract the joomla installer (VM will be installed from the package later
tar cf - --one-file-system -C /usr/src/joomla . | tar xf -
for p in /usr/src/virtuemart/*.zip; do if [ -e htaccess.txt -a ! -e .htaccess ]; then
sudo -u www-data php ./cli/install-joomla-extension.php --package=$p # NOTE: The "Indexes" option is disabled in the php:apache base image so remove it as we enable .htaccess
done sed -r 's/^(Options -Indexes.*)$/#\1/' htaccess.txt > .htaccess
chown www-data:www-data .htaccess
fi
echo >&2 "Complete! Joomla has been successfully copied to $(pwd)"
fi
# Now run the joomla Installer:
: ${JOOMLA_ADMIN_USER:=admin}
: ${JOOMLA_ADMIN_PASSWORD:=admin}
: ${JOOMLA_ADMIN_EMAIL:=admin@example.com}
: ${JOOMLA_SITE_NAME:=Joomla Installation}
if [ -z "$JOOMLA_DB_PREFIX" ]; then
DBPREFIX="--dbprefix=\"${JOOMLA_DB_PREFIX}_\""
fi
php ./installation/install.php --name "$JOOMLA_SITE_NAME" \
--admin-user "$JOOMLA_ADMIN_USER" --admin-pass "$JOOMLA_ADMIN_PASSWORD" --admin-email "$JOOMLA_ADMIN_EMAIL" \
--db-host "$JOOMLA_DB_HOST" --db-user "$JOOMLA_DB_USER" --db-pass "$JOOMLA_DB_PASSWORD" --db-name "$JOOMLA_DB_NAME" $DBPREFIX && \
rm -rf "./installation/"
for p in /usr/src/virtuemart/*.zip; do
sudo -u www-data php ./cli/install-joomla-extension.php --package=$p
done
if [ "$MYSQL_LOCAL" = "1" ]; then
# Local installation, so shut down MySQL again, will later be started through supervisord
echo "Shutting down temporary MySQL instance ..."
/usr/bin/mysqladmin --user=root --password="${JOOMLA_DB_PASSWORD}" shutdown
fi
echo >&2 "========================================================================"
echo >&2
echo >&2 "This server is now configured to run Joomla!"
echo >&2 "You will need the following database information to install Joomla:"
echo >&2 "Host Name: $JOOMLA_DB_HOST"
echo >&2 "Database Name: $JOOMLA_DB_NAME"
echo >&2 "Database Username: $JOOMLA_DB_USER"
echo >&2 "Database Password: $JOOMLA_DB_PASSWORD"
echo >&2
echo >&2 "Joomla admin user: $JOOMLA_ADMIN_USER"
echo >&2 "Joomla admin password: $JOOMLA_ADMIN_PASSWORD"
echo >&2
echo >&2 "========================================================================"
# create the file to indicate this container has been configured:
touch /etc/opentools-docker-configured
fi fi
exec "$@" exec "$@"
[supervisord]
nodaemon=true
[program:apache]
command=/usr/local/bin/apache2-foreground
autorestart=true
[include]
files = /etc/supervisor/conf.d/*.conf
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment