Skip to content

Instantly share code, notes, and snippets.

@miljan-aleksic miljan-aleksic/Dockerfile
Last active Jan 22, 2018

Embed
What would you like to do?
Docker with Joomlatols
version: '3.1'
services:
joomla:
image: myImage
restart: always
links:
- joomla-db:mysql
ports:
- 8080:80
environment:
JOOMLA_DB_HOST: joomla-db
JOOMLA_DB_PASSWORD: root
volumes:
- ./:/var/www/html
joomla-db:
image: mysql:5.6
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
#!/bin/bash
set -e
if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
if [ -z "$JOOMLA_DB_HOST" ]; then
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
# 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
: ${JOOMLA_DB_NAME:=joomla}
if [ -z "$JOOMLA_DB_PASSWORD" ] && [ "$JOOMLA_DB_PASSWORD_ALLOW_EMPTY" != 'yes' ]; 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 JOOMLA_DB_USER and JOOMLA_DB_NAME.)"
exit 1
fi
if ! [ -e index.php -a \( -e libraries/cms/version/version.php -o -e libraries/src/Version.php \) ]; then
echo >&2 "Joomla not found in $(pwd) - copying now..."
if [ "$(ls -A)" ]; then
echo >&2 "WARNING: $(pwd) is not empty - press Ctrl+C now if this is an error!"
( set -x; ls -A; sleep 10 )
fi
tar cf - --one-file-system -C /usr/src/joomla . | tar xf -
if [ ! -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
echo >&2 "Complete! Joomla has been successfully copied to $(pwd)"
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 console is available here, do whatever further action required. Eg.
# joomla site:configure \
# --mysql-host=$JOOMLA_DB_HOST \
# --mysql-database=$JOOMLA_DB_NAME \
# --mysql-login=$JOOMLA_DB_USER:$JOOMLA_DB_PASSWORD \
# --overwrite \
# --options=/joomla/config.yml \
# html
fi
exec "$@"
FROM composer:1.5 AS builder
RUN composer global require joomlatools/console
FROM php:7.0-apache
# Disable remote database security requirements.
ENV JOOMLA_INSTALLATION_DISABLE_LOCALHOST_CHECK=1
# Enable Apache Rewrite Module
RUN a2enmod rewrite
# Install PHP extensions
RUN apt-get update && apt-get install -y mysql-client libpng12-dev libjpeg-dev libmcrypt-dev zip unzip && rm -rf /var/lib/apt/lists/* \
&& docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \
&& docker-php-ext-install gd
RUN docker-php-ext-install mysqli
RUN docker-php-ext-install mcrypt
RUN docker-php-ext-install zip
# required by zl fw
RUN docker-php-ext-install bcmath
RUN docker-php-ext-install pdo pdo_mysql
# Increase upload limits
RUN echo 'file_uploads = On\n' \
'memory_limit = 500M\n' \
'upload_max_filesize = 500M\n' \
'post_max_size = 500M\n' \
'max_execution_time = 600\n' \
> /usr/local/etc/php/conf.d/uploads.ini
VOLUME /var/www/html
# Set joomlatools console
COPY --from=builder /tmp/vendor /root/.composer/vendor
ENV PATH="$PATH:/root/.composer/vendor/bin"
# Define Joomla version and expected SHA1 signature
ENV JOOMLA_VERSION 3.8.3
ENV JOOMLA_SHA1 1b1f378cdb04b090d9b49987ab8c0eeff30bc0d5
# Download package and extract to web volume
RUN curl -o joomla.zip -SL https://github.com/joomla/joomla-cms/releases/download/${JOOMLA_VERSION}/Joomla_${JOOMLA_VERSION}-Stable-Full_Package.zip \
&& echo "$JOOMLA_SHA1 *joomla.zip" | sha1sum -c - \
&& mkdir /usr/src/joomla \
&& unzip joomla.zip -d /usr/src/joomla \
&& rm joomla.zip \
&& chown -R www-data:www-data /usr/src/joomla
# Copy init scripts
COPY docker-entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["apache2-foreground"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.