diff --git a/README.md b/README.md index fbfcad8355857f1f78695132097c9dffb1ad6748..e3fd80c27ed4530d8b34781b27ae3a9ce56b83db 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,62 @@ -# What is VirtueMart +### What is VirtueMart Virtuemart is a full-feature e-Commerce suite, which relies on and needs to be installed inside Joomla. For further information see http://www.virtuemart.net/ -# About this image and its requirements +### Virtuemart 3.x on Joomla 2.5.28 (Full installer) + +The stock VirtueMart full installer provides a pre-configured Joomla 2.5.28 installation with sample data installed and the front end already set up with the cart, category and product pages. You can install it from the `opentools/docker-virtuemart:fullinstaller` tag (this assumes an existing mysql container for the database to be linked): + +```console +$ docker run --name some-virtuemart --link some-mysql:mysql -d \ + -p 8080:80 opentools/docker-virtuemart:fullinstaller +``` + +This will set up the database and the joomla/virtuemart files, but will leave the installation to you. Simply go to http://localhost:8080/ to run the installer. Unless you changed the defaults with the env variables listed above, the database credentials are: +- database host: mysql +- database: virtuemart +- database user: root +- database password: (the MYSQL_ROOT_PASSWORD given when the mysql container was created) +The Joomla installer will already be prefilled with these values (or the ones you gave in the environment variables). + +### Virtuemart 3.x on Joomla 3.x (automated installation) + +There is no full installer for VirtueMart 3.x on Joomla 3.x, so this image installed Joomla 3.x and then the Virtuemart 3.x packages, which provide sample data, but do not set up the Joomla front end with the cart, category and product menus and pages. The installation of Joomla and Virtuemart can mostly be done automatically, so in this case, there is no need to go through the installer. However, to configure Joomla, you can give the database prefix, the site name, the admin user/password etc. as env variables when the container is created: + +A typical installation of Joomla 3.x with VirtueMart 3.x will thus use a docker line like: +```console +$ docker run --name=some-virtuemart -e JOOMLA_DB_NAME=joomla_j3vm3 \ + -e JOOMLA_DB_PREFIX=vm3 -e JOOMLA_SITE_NAME="My VirtueMart Installation" \ + --link some-mysql:mysql -p 8080:80 -d opentools/docker-virtuemart:j3vm3 +``` + +Available env variables are: `JOOMLA_ADMIN_USER`, `JOOMLA_ADMIN_PASSWORD`, `JOOMLA_ADMIN_EMAIL`, `JOOMLA_SITE_NAME`, `JOOMLA_DB_PREFIX`. + +Joomla and Virtuemart itself can be set up automatically, but for technical reasons (Joomla does not have a clean separation of installation and GUI features), the Virtuemart EXT AIO cannot be installed automatically. So after installation, you need to go to Joomla's backend extensions page +``` +http://localhost:8080/administrator/index.php?option=com_installer&view=install``` +and install the Virtuemart EXT AIO package from the folder +``` +/usr/src/virtuemart/com_virtumart_ext_aio/ +``` + +### Virtuemart 2.6 on Joomla 2.5 (Full installer) + +The stock VirtueMart full installer of the (outdated) Virtuemart 2.6 provides a pre-configured Joomla 2.5.27 installation with sample data installed and the front end already set up with the cart, category and product pages. You can install it from the `opentools/docker-virtuemart:fullinstaller` tag (this assumes an existing mysql container for the database to be linked): + +```console +$ docker run --name some-virtuemart --link some-mysql:mysql -d \ + -p 8080:80 opentools/docker-virtuemart:j2vm2_full +``` + +This will set up the database and the joomla/virtuemart files, but will leave the installation to you. Simply go to http://localhost:8080/ to run the installer. Unless you changed the defaults with the env variables listed above, the database credentials are: +- database host: mysql +- database: j2vm2 +- database user: root +- database password: (the MYSQL_ROOT_PASSWORD given when the mysql container was created) + + + +### About this image and its requirements This docker image provides the stock VirtueMart installation. There are tags for the full installer (which includes Joomla 2.5.28 and Virtuemart 3.x including sample products) and for a Joomla 3 installation (latest Joomla with Virtuemart 3.x, no sample products will be set up). Unless you configure the image differently, the MySQL database connection to the linked mysql contaner will be: @@ -22,15 +76,18 @@ This mysql container can then be linked to the virtuemart container as described # Which tags / variants are available for this image? - - `opentools/docker-virtuemart:fullinstall` ... The stock fullinstaller provided by the VirtueMart Team (Joomla 2.5.28, Virtuemart 3.0.10). Automatic installation not possible, but the joomla installer will be run when you point your webbrowser to this container (see below). + - `opentools/docker-virtuemart:fullinstaller` ... The stock fullinstaller provided by the VirtueMart Team (Joomla 2.5.28, Virtuemart 3.0.10). Automatic installation not possible, but the joomla installer will be run when you point your webbrowser to this container (see below). - `opentools/docker-virtuemart:j3vm3` ... Joomla 3 installation with Virtuemart 3.x. Automatic installation of Joomla and VirtueMart is attempted, admin username, password, email etc. are passed as env variables (see below) -# How to use this image + - `opentools/docker-virtuemart:j2vm2_full` ... The stock fullinstaller provided by the VirtueMart Team with VirtueMart 2.x (Joomla 2.5.28, Virtuemart 2.6). Automatic installation not possible, but the joomla installer will be run when you point your webbrowser to this container (see below). + + +### How to use this image ```console $ docker run --name some-virtuemart --link some-mysql:mysql -d opentools/virtuemart:tag ``` -where `tag` is either `fullinstall` (for the VM 3.0.10 full installer on Joomla 2.5.28, including sample data) or `j3vm3` for an automatic installation of VM 3.0.10 on Joomla 3.x (but no sample data). +where `tag` is either `fullinstaller` (for the VM 3.0.10 full installer on Joomla 2.5.28, including sample data), `j3vm3` for an automatic installation of VM 3.0.10 on Joomla 3.x (but no sample data) or `j2vm2_full` for VirtueMart 2.x on Joomla 2.5 (fullinstaller). The following environment variables are also honored for configuring your Joomla instance: @@ -63,40 +120,6 @@ $ docker run --name some-virtuemart -e JOOMLA_DB_HOST=10.1.2.3:3306 \ -e JOOMLA_DB_USER=... -e JOOMLA_DB_PASSWORD=... -d opentools/virtuemart:tag ``` -# Virtuemart 3.x on Joomla 2.5.28 (Full installer) - -The stock VirtueMart full installer provides a pre-configured Joomla 2.5.28 installation with sample data installed and the front end already set up with the cart, category and product pages. You can install it from the `opentools/docker-virtuemart:fullinstaller` tag: - -```console -$ docker run --name some-virtuemart --link some-mysql:mysql -d \ - -p 8080:80 opentools/virtuemart:fullinstaller -``` - -This will set up the database and the joomla/virtuemart files, but will leave the installation to you. Simply go to http://localhost:8080/ to run the installer. Unless you changed the defaults with the env variables listed above, the database credentials are: -- database host: mysql -- database: virtuemart -- database user: root -- database password: (the MYSQL_ROOT_PASSWORD given when the mysql container was created) - -# Virtuemart 3.x on Joomla 3.x (automated installation) - -There is no full installer for VirtueMart 3.x on Joomla 3.x, so this image installed Joomla 3.x and then the Virtuemart 3.x packages, which provide sample data, but do not set up the Joomla front end with the cart, category and product menus and pages. The installation of Joomla and Virtuemart can mostly be done automatically, so in this case, there is no need to go through the installer. However, to configure Joomla, you can give the database prefix, the site name, the admin user/password etc. as env variables when the container is created: - -A typical installation of Joomla 3.x with VirtueMart 3.x will thus use a docker line like: -```console -$ docker run --name=some-virtuemart -e JOOMLA_DB_NAME=joomla_j3vm3 -e JOOMLA_DB_PREFIX=vm3 -e JOOMLA_SITE_NAME="My VirtueMart Installation" --link some-mysql:mysql -p 8080:80 -d opentools/virtuemart:j3vm3 -``` - -Available env variables are: `JOOMLA_ADMIN_USER`, `JOOMLA_ADMIN_PASSWORD`, `JOOMLA_ADMIN_EMAIL`, `JOOMLA_SITE_NAME`, `JOOMLA_DB_PREFIX`. - -Joomla and Virtuemart itself can be set up automatically, but for technical reasons (Joomla does not have a clean separation of installation and GUI features), the Virtuemart EXT AIO cannot be installed automatically. So after installation, you need to go to Joomla's backend extensions page -``` -http://localhost:8080/administrator/index.php?option=com_installer&view=install``` -and install the Virtuemart EXT AIO package from the folder -``` -/usr/src/virtuemart/com_virtumart_ext_aio/ -``` - -# Sources +### Sources The docker files to build these images are available on github under the GPL: https://github.com/open-tools/docker-virtuemart diff --git a/j2vm2_full/docker-entrypoint.sh b/j2vm2_full/docker-entrypoint.sh index 44e92040e20c819c2767db633a4e3badb7f24934..52cb7b48fec3d9cfbe65c425e01a5b281f16376d 100755 --- a/j2vm2_full/docker-entrypoint.sh +++ b/j2vm2_full/docker-entrypoint.sh @@ -4,34 +4,59 @@ set -e if [[ "$1" == apache2* ]]; then if [ -n "$MYSQL_PORT_3306_TCP" ]; then - if [ -z "$VM_DB_HOST" ]; then - VM_DB_HOST='mysql' + if [ -z "$JOOMLA_DB_HOST" ]; then + JOOMLA_DB_HOST='mysql' else - echo >&2 "warning: both VM_DB_HOST and MYSQL_PORT_3306_TCP found" - echo >&2 " Connecting to VM_DB_HOST ($VM_DB_HOST)" + 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 [ -z "$VM_DB_HOST" ]; then - echo >&2 "error: missing VM_DB_HOST and MYSQL_PORT_3306_TCP environment variables" - echo >&2 " Did you forget to --link some_mysql_container:mysql or set an external db" - echo >&2 " with -e VM_DB_HOST=hostname:port?" - exit 1 + # If the DB user is 'root' then use the MySQL root password env var + : ${JOOMLA_DB_USER:=root} + if [ "$JOOMLA_DB_USER" = 'root' ]; then + : ${JOOMLA_DB_PASSWORD:=$MYSQL_ENV_MYSQL_ROOT_PASSWORD} fi + if [ -z "$JOOMLA_DB_HOST" ]; then + 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}." + + export DEBIAN_FRONTEND=noninteractive - # If the DB user is 'root' then use the MySQL root password env var - : ${VM_DB_USER:=root} - if [ "$VM_DB_USER" = 'root' ]; then - : ${VM_DB_PASSWORD:=$MYSQL_ENV_MYSQL_ROOT_PASSWORD} + 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 +# echo 'phpmyadmin phpmyadmin/dbconfig-install boolean true' | debconf-set-selections +# 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/* ) +# echo >&2 "error: missing JOOMLA_DB_HOST and MYSQL_PORT_3306_TCP environment variables" +# echo >&2 " Did you forget to --link some_mysql_container:mysql or set an external db" +# echo >&2 " with -e JOOMLA_DB_HOST=hostname:port?" +# exit 1 fi - : ${VM_DB_NAME:=j2vm2} + if [ -n "$MYSQL_LOCAL" ]; then + echo >&2 "Starting MySQL daemon..." + service mysql restart + fi + + : ${JOOMLA_DB_NAME:=j2vm2 - if [ -z "$VM_DB_PASSWORD" ]; then - echo >&2 "error: missing required VM_DB_PASSWORD environment variable" - echo >&2 " Did you forget to -e VM_DB_PASSWORD=... ?" + if [ -z "$JOOMLA_DB_PASSWORD" ]; then + echo >&2 "error: missing required JOOMLA_DB_PASSWORD environment variable" + echo >&2 " Did you forget to -e JOOMLA_DB_PASSWORD=... ?" echo >&2 - echo >&2 " (Also of interest might be VM_DB_USER and VM_DB_NAME.)" + echo >&2 " (Also of interest might be JOOMLA_DB_USER and JOOMLA_DB_NAME.)" exit 1 fi @@ -50,21 +75,27 @@ if [[ "$1" == apache2* ]]; then sed -r 's/^(Options -Indexes.*)$/#\1/' htaccess.txt > .htaccess chown www-data:www-data .htaccess fi + + 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)" fi # Ensure the MySQL Database is created - php /makedb.php "$VM_DB_HOST" "$VM_DB_USER" "$VM_DB_PASSWORD" "$VM_DB_NAME" + php /makedb.php "$JOOMLA_DB_HOST" "$JOOMLA_DB_USER" "$JOOMLA_DB_PASSWORD" "$JOOMLA_DB_NAME" 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: $VM_DB_HOST" - echo >&2 "Database Name: $VM_DB_NAME" - echo >&2 "Database Username: $VM_DB_USER" - echo >&2 "Database Password: $VM_DB_PASSWORD" + 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 "========================================================================" fi diff --git a/j2vm3_full/Dockerfile b/j2vm3_full/Dockerfile index fab2af61935e739434a47a7af4a30a6a25addc86..241aa577b161fc1c8adb3785fc4fe505cb1b569e 100644 --- a/j2vm3_full/Dockerfile +++ b/j2vm3_full/Dockerfile @@ -13,12 +13,16 @@ RUN docker-php-ext-install mysqli VOLUME /var/www/html +# Install MySQL (will only be started if needed) +# RUN apt-get update && apt-get install -y mysql-server && rm -rf /var/lib/apt/lists/* + + # Define Joomla version and expected SHA1 signature -ENV VMFULL_VERSION 3.0.10 -ENV VMFULL_MD5 f10c0e702a89751382beaba04a094e90 +ENV VMFULL_VERSION 3.0.12 +ENV VMFULL_MD5 7e6bef1cff409042ea6efd20e582938e # Download package and extract to web volume -RUN curl -o virtuemart.zip -SL http://dev.virtuemart.net/attachments/download/973/VirtueMart${VMFULL_VERSION}_Joomla_2.5.28-Stable-Full_Package.zip \ +RUN curl -o virtuemart.zip -SL http://dev.virtuemart.net/attachments/download/980/VirtueMart${VMFULL_VERSION}_Joomla_2.5.28-Stable-Full_Package.zip \ && echo "$VMFULL_MD5 *virtuemart.zip" | md5sum -c - \ && mkdir /usr/src/virtuemart \ && unzip virtuemart.zip -d /usr/src/virtuemart \ diff --git a/j2vm3_full/docker-entrypoint.sh b/j2vm3_full/docker-entrypoint.sh index 811c5b44995f693ead56f262c033d39d8d832b75..e00b2bb7077a9a378bae37686d850488975e563a 100755 --- a/j2vm3_full/docker-entrypoint.sh +++ b/j2vm3_full/docker-entrypoint.sh @@ -4,34 +4,59 @@ set -e if [[ "$1" == apache2* ]]; then if [ -n "$MYSQL_PORT_3306_TCP" ]; then - if [ -z "$VM_DB_HOST" ]; then - VM_DB_HOST='mysql' + if [ -z "$JOOMLA_DB_HOST" ]; then + JOOMLA_DB_HOST='mysql' else - echo >&2 "warning: both VM_DB_HOST and MYSQL_PORT_3306_TCP found" - echo >&2 " Connecting to VM_DB_HOST ($VM_DB_HOST)" + 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 [ -z "$VM_DB_HOST" ]; then - echo >&2 "error: missing VM_DB_HOST and MYSQL_PORT_3306_TCP environment variables" - echo >&2 " Did you forget to --link some_mysql_container:mysql or set an external db" - echo >&2 " with -e VM_DB_HOST=hostname:port?" - exit 1 + # If the DB user is 'root' then use the MySQL root password env var + : ${JOOMLA_DB_USER:=root} + if [ "$JOOMLA_DB_USER" = 'root' ]; then + : ${JOOMLA_DB_PASSWORD:=$MYSQL_ENV_MYSQL_ROOT_PASSWORD} fi + if [ -z "$JOOMLA_DB_HOST" ]; then + 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}." + + export DEBIAN_FRONTEND=noninteractive - # If the DB user is 'root' then use the MySQL root password env var - : ${VM_DB_USER:=root} - if [ "$VM_DB_USER" = 'root' ]; then - : ${VM_DB_PASSWORD:=$MYSQL_ENV_MYSQL_ROOT_PASSWORD} + 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 +# echo 'phpmyadmin phpmyadmin/dbconfig-install boolean true' | debconf-set-selections +# 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/* ) +# echo >&2 "error: missing JOOMLA_DB_HOST and MYSQL_PORT_3306_TCP environment variables" +# echo >&2 " Did you forget to --link some_mysql_container:mysql or set an external db" +# echo >&2 " with -e JOOMLA_DB_HOST=hostname:port?" +# exit 1 fi - : ${VM_DB_NAME:=virtuemart} + if [ -n "$MYSQL_LOCAL" ]; then + echo >&2 "Starting MySQL daemon..." + service mysql restart + fi + + : ${JOOMLA_DB_NAME:=virtuemart} - if [ -z "$VM_DB_PASSWORD" ]; then - echo >&2 "error: missing required VM_DB_PASSWORD environment variable" - echo >&2 " Did you forget to -e VM_DB_PASSWORD=... ?" + if [ -z "$JOOMLA_DB_PASSWORD" ]; then + echo >&2 "error: missing required JOOMLA_DB_PASSWORD environment variable" + echo >&2 " Did you forget to -e JOOMLA_DB_PASSWORD=... ?" echo >&2 - echo >&2 " (Also of interest might be VM_DB_USER and VM_DB_NAME.)" + echo >&2 " (Also of interest might be JOOMLA_DB_USER and JOOMLA_DB_NAME.)" exit 1 fi @@ -50,21 +75,27 @@ if [[ "$1" == apache2* ]]; then sed -r 's/^(Options -Indexes.*)$/#\1/' htaccess.txt > .htaccess chown www-data:www-data .htaccess fi + + 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)" fi # Ensure the MySQL Database is created - php /makedb.php "$VM_DB_HOST" "$VM_DB_USER" "$VM_DB_PASSWORD" "$VM_DB_NAME" + php /makedb.php "$JOOMLA_DB_HOST" "$JOOMLA_DB_USER" "$JOOMLA_DB_PASSWORD" "$JOOMLA_DB_NAME" 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: $VM_DB_HOST" - echo >&2 "Database Name: $VM_DB_NAME" - echo >&2 "Database Username: $VM_DB_USER" - echo >&2 "Database Password: $VM_DB_PASSWORD" + 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 "========================================================================" fi