Skip to content

Commit

Permalink
Implement image templating (meanbee#102)
Browse files Browse the repository at this point in the history
* Use templating to build the PHP images

* Use PHP 7.0 in the example Docker Compose files

We can't install a version of Magento that's compatible with 7.1 at the moment

* Fix CS issues in the Builder script

* Add instructions on building
  • Loading branch information
punkstar authored Sep 18, 2017
1 parent 7d60d1e commit 5eee04b
Show file tree
Hide file tree
Showing 30 changed files with 1,409 additions and 175 deletions.
72 changes: 36 additions & 36 deletions 7.0-cli/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#
# Command line, PHP 7.0, Magento 2 compatible container.
#
# Credit to Mark Shust <mark.shust@mageinferno.com> for the basis of this
# Dockerfile in the https://github.com/mageinferno/docker-magento2-php project.
# This file is automatically generated. Do not edit directly.
#

FROM php:7.0-cli
Expand All @@ -12,19 +9,19 @@ MAINTAINER Nick Jones <nick@nicksays.co.uk>
# Install dependencies
RUN apt-get update \
&& apt-get install -y \
cron \
rsyslog \
libfreetype6-dev \
libicu-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng12-dev \
libxslt1-dev \
mysql-client \
git \
sendmail-bin \
sendmail \
sudo
libfreetype6-dev \
libicu-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng12-dev \
libxslt1-dev \
sendmail-bin \
sendmail \
sudo \
cron \
rsyslog \
mysql-client \
git

# Configure the gd library
RUN docker-php-ext-configure \
Expand All @@ -45,6 +42,28 @@ RUN docker-php-ext-install \
# Install the 2.4 version of xdebug that's compatible with php7
RUN pecl install -o -f xdebug-2.4.0

ENV PHP_MEMORY_LIMIT 2G
ENV PHP_ENABLE_XDEBUG false
ENV MAGENTO_ROOT /var/www/magento

ENV DEBUG false
ENV UPDATE_UID_GID false

ADD docker-entrypoint.sh /docker-entrypoint.sh

RUN ["chmod", "+x", "/docker-entrypoint.sh"]

ENTRYPOINT ["/docker-entrypoint.sh"]

ENV COMPOSER_ALLOW_SUPERUSER 1
ENV COMPOSER_GITHUB_TOKEN ""
ENV COMPOSER_MAGENTO_USERNAME ""
ENV COMPOSER_MAGENTO_PASSWORD ""
ENV COMPOSER_BITBUCKET_KEY ""
ENV COMPOSER_BITBUCKET_SECRET ""

VOLUME /root/.composer/cache

# Get composer installed to /usr/local/bin/composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

Expand All @@ -57,33 +76,14 @@ RUN curl -LO https://s3.eu-west-2.amazonaws.com/magedbm2-releases/magedbm2.phar
# Install mageconfigsync and move to /usr/local/bin
RUN curl -L https://github.com/punkstar/mageconfigsync/releases/download/0.5.0-beta.1/mageconfigsync-0.5.0-beta.1.phar > mageconfigsync.phar && chmod +x ./mageconfigsync.phar && mv ./mageconfigsync.phar /usr/local/bin

VOLUME /root/.composer/cache

ADD bin/* /usr/local/bin/
ADD etc/php.ini /usr/local/etc/php/conf.d/zz-magento.ini
ADD etc/php-xdebug.ini /usr/local/etc/php/conf.d/zz-xdebug-settings.ini
ADD etc/mail.ini /usr/local/etc/php/conf.d/zz-mail.ini

ENV PHP_MEMORY_LIMIT 2G
ENV PHP_ENABLE_XDEBUG false
ENV MAGENTO_ROOT /var/www/magento

ENV COMPOSER_ALLOW_SUPERUSER 1
ENV COMPOSER_GITHUB_TOKEN ""
ENV COMPOSER_MAGENTO_USERNAME ""
ENV COMPOSER_MAGENTO_PASSWORD ""
ENV COMPOSER_BITBUCKET_KEY ""
ENV COMPOSER_BITBUCKET_SECRET ""
ENV DEBUG false
ENV UPDATE_UID_GID false
ENV UPLOAD_MAX_FILESIZE 64M

RUN ["chmod", "+x", "/usr/local/bin/docker-environment"]
RUN ["chmod", "+x", "/usr/local/bin/magento-installer"]
RUN ["chmod", "+x", "/usr/local/bin/magento-command"]
RUN ["chmod", "+x", "/usr/local/bin/magerun2"]
RUN ["chmod", "+x", "/usr/local/bin/run-cron"]

ENTRYPOINT ["/usr/local/bin/docker-environment"]

CMD ["bash"]
13 changes: 9 additions & 4 deletions 7.0-cli/bin/docker-environment → 7.0-cli/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ fi
mkdir -p $MAGENTO_ROOT
chown www-data:www-data $MAGENTO_ROOT


CRON_LOG=/var/log/cron.log

# Setup Magento cron
Expand All @@ -43,29 +44,33 @@ touch $CRON_LOG
echo "cron.* $CRON_LOG" > /etc/rsyslog.d/cron.conf
service rsyslog start



# Configure Sendmail if required
if [ "$ENABLE_SENDMAIL" == "true" ]; then
/etc/init.d/sendmail start
fi


# Configure PHP
# Substitute in php.ini values
[ ! -z "${PHP_MEMORY_LIMIT}" ] && sed -i "s/!PHP_MEMORY_LIMIT!/${PHP_MEMORY_LIMIT}/" /usr/local/etc/php/conf.d/zz-magento.ini
[ ! -z "${UPLOAD_MAX_FILESIZE}" ] && sed -i "s/!UPLOAD_MAX_FILESIZE!/${UPLOAD_MAX_FILESIZE}/" /usr/local/etc/php/conf.d/zz-magento.ini

[ "$PHP_ENABLE_XDEBUG" = "true" ] && \
docker-php-ext-enable xdebug && \
echo "Xdebug is enabled"


# Configure composer
[ ! -z "${COMPOSER_GITHUB_TOKEN}" ] && \
composer config --global github-oauth.github.com $COMPOSER_GITHUB_TOKEN

[ ! -z "${COMPOSER_MAGENTO_USERNAME}" ] && \
composer config --global http-basic.repo.magento.com \
$COMPOSER_MAGENTO_USERNAME $COMPOSER_MAGENTO_PASSWORD

[ ! -z "${COMPOSER_BITBUCKET_KEY}" ] && [ ! -z "${COMPOSER_BITBUCKET_SECRET}" ] && \
composer config --global bitbucket-oauth.bitbucket.org $COMPOSER_BITBUCKET_KEY $COMPOSER_BITBUCKET_SECRET
composer config --global bitbucket-oauth.bitbucket.org $COMPOSER_BITBUCKET_KEY $COMPOSER_BITBUCKET_SECRET


exec "$@"

44 changes: 19 additions & 25 deletions 7.0-fpm/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#
# FPM, PHP 7.0, Magento 2 compatible container.
#
# Credit to Mark Shust <mark.shust@mageinferno.com> for the basis of this
# Dockerfile in the https://github.com/mageinferno/docker-magento2-php project.
# This file is automatically generated. Do not edit directly.
#

FROM php:7.0-fpm
Expand All @@ -12,15 +9,15 @@ MAINTAINER Nick Jones <nick@nicksays.co.uk>
# Install dependencies
RUN apt-get update \
&& apt-get install -y \
cron \
libfreetype6-dev \
libicu-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng12-dev \
libxslt1-dev \
sendmail-bin \
sendmail
libfreetype6-dev \
libicu-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng12-dev \
libxslt1-dev \
sendmail-bin \
sendmail \
sudo

# Configure the gd library
RUN docker-php-ext-configure \
Expand All @@ -41,23 +38,20 @@ RUN docker-php-ext-install \
# Install the 2.4 version of xdebug that's compatible with php7
RUN pecl install -o -f xdebug-2.4.0

VOLUME /root/.composer/cache

ADD bin/* /usr/local/bin/
ADD etc/php.ini /usr/local/etc/php/conf.d/zz-magento.ini
ADD etc/mail.ini /usr/local/etc/php/conf.d/zz-mail.ini
ADD etc/php-xdebug.ini /usr/local/etc/php/conf.d/zz-xdebug-settings.ini
ADD etc/php-fpm.conf /usr/local/etc/

ENV PHP_MEMORY_LIMIT 2G
ENV PHP_ENABLE_XDEBUG false
ENV MAGENTO_ROOT /var/www/magento
ENV MAGENTO_RUN_MODE developer

ENV DEBUG false
ENV UPDATE_UID_GID false
ENV UPLOAD_MAX_FILESIZE 64M

RUN ["chmod", "+x", "/usr/local/bin/docker-environment"]
ADD docker-entrypoint.sh /docker-entrypoint.sh

RUN ["chmod", "+x", "/docker-entrypoint.sh"]

ENTRYPOINT ["/docker-entrypoint.sh"]

ENV MAGENTO_RUN_MODE developer
ENV UPLOAD_MAX_FILESIZE 64M

ENTRYPOINT ["/usr/local/bin/docker-environment"]
CMD ["php-fpm", "-F"]
11 changes: 10 additions & 1 deletion 7.0-fpm/bin/docker-environment → 7.0-fpm/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,29 @@ if [[ "$UPDATE_UID_GID" = "true" ]]; then
groupmod -g $DOCKER_GID www-data
fi

# Ensure our Magento directory exists
mkdir -p $MAGENTO_ROOT
chown www-data:www-data $MAGENTO_ROOT



# Configure Sendmail if required
if [ "$ENABLE_SENDMAIL" == "true" ]; then
/etc/init.d/sendmail start
fi

# Configure PHP
# Substitute in php.ini values
[ ! -z "${PHP_MEMORY_LIMIT}" ] && sed -i "s/!PHP_MEMORY_LIMIT!/${PHP_MEMORY_LIMIT}/" /usr/local/etc/php/conf.d/zz-magento.ini
[ ! -z "${UPLOAD_MAX_FILESIZE}" ] && sed -i "s/!UPLOAD_MAX_FILESIZE!/${UPLOAD_MAX_FILESIZE}/" /usr/local/etc/php/conf.d/zz-magento.ini

[ "$PHP_ENABLE_XDEBUG" = "true" ] && \
docker-php-ext-enable xdebug && \
echo "Xdebug is enabled"


# Configure PHP-FPM
[ ! -z "${MAGENTO_RUN_MODE}" ] && sed -i "s/!MAGENTO_RUN_MODE!/${MAGENTO_RUN_MODE}/" /usr/local/etc/php-fpm.conf


exec "$@"

3 changes: 0 additions & 3 deletions 7.0-fpm/etc/php.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
; This file is created automatically by the docker build

memory_limit = !PHP_MEMORY_LIMIT! ; Variable: PHP_MEMORY_LIMIT
upload_max_filesize = !UPLOAD_MAX_FILESIZE! ; Variable: UPLOAD_MAX_FILESIZE
post_max_size = !UPLOAD_MAX_FILESIZE! ; Variable: UPLOAD_MAX_FILESIZE

82 changes: 56 additions & 26 deletions 7.1-cli/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
#
# Command line, PHP 7.1, Magento 2 compatible container.
#
# Credit to Mark Shust <mark.shust@mageinferno.com> for the basis of this
# Dockerfile in the https://github.com/mageinferno/docker-magento2-php project.
# This file is automatically generated. Do not edit directly.
#

FROM php:7.1-cli

MAINTAINER Adam Paterson <hello@adampaterson.co.uk>
MAINTAINER Nick Jones <nick@nicksays.co.uk>

# Install dependencies
RUN apt-get update \
&& apt-get install -y \
cron \
libfreetype6-dev \
libicu-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng12-dev \
libxslt1-dev \
sendmail-bin \
sendmail
&& apt-get install -y \
libfreetype6-dev \
libicu-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng12-dev \
libxslt1-dev \
sendmail-bin \
sendmail \
sudo \
cron \
rsyslog \
mysql-client \
git

# Configure the gd library
RUN docker-php-ext-configure \
gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include
gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/

# Install required PHP extensions
RUN docker-php-ext-install \
dom \
gd \
intl \
mbstring \
Expand All @@ -40,20 +42,48 @@ RUN docker-php-ext-install \
# Install the 2.4 version of xdebug that's compatible with php7
RUN pecl install -o -f xdebug-2.4.0

ENV PHP_MEMORY_LIMIT 2G
ENV PHP_ENABLE_XDEBUG false
ENV MAGENTO_ROOT /var/www/magento

ENV DEBUG false
ENV UPDATE_UID_GID false

ADD docker-entrypoint.sh /docker-entrypoint.sh

RUN ["chmod", "+x", "/docker-entrypoint.sh"]

ENTRYPOINT ["/docker-entrypoint.sh"]

ENV COMPOSER_ALLOW_SUPERUSER 1
ENV COMPOSER_GITHUB_TOKEN ""
ENV COMPOSER_MAGENTO_USERNAME ""
ENV COMPOSER_MAGENTO_PASSWORD ""
ENV COMPOSER_BITBUCKET_KEY ""
ENV COMPOSER_BITBUCKET_SECRET ""

VOLUME /root/.composer/cache

# Get composer installed to /usr/local/bin/composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Install n98-magerun2.phar and move to /usr/local/bin/
RUN curl -O https://files.magerun.net/n98-magerun2.phar && chmod +x ./n98-magerun2.phar && mv ./n98-magerun2.phar /usr/local/bin/

# Install magedbm2.phar and move to /usr/local/bin
RUN curl -LO https://s3.eu-west-2.amazonaws.com/magedbm2-releases/magedbm2.phar && chmod +x ./magedbm2.phar && mv ./magedbm2.phar /usr/local/bin

# Install mageconfigsync and move to /usr/local/bin
RUN curl -L https://github.com/punkstar/mageconfigsync/releases/download/0.5.0-beta.1/mageconfigsync-0.5.0-beta.1.phar > mageconfigsync.phar && chmod +x ./mageconfigsync.phar && mv ./mageconfigsync.phar /usr/local/bin

ADD bin/* /usr/local/bin/
ADD etc/php.ini /usr/local/etc/php/conf.d/zz-magento.ini
ADD etc/mail.ini /usr/local/etc/php/conf.d/zz-mail.ini
ADD etc/php-xdebug.ini /usr/local/etc/php/conf.d/zz-xdebug-settings.ini
ADD etc/php-fpm.conf /usr/local/etc/
ADD etc/mail.ini /usr/local/etc/php/conf.d/zz-mail.ini

ENV PHP_MEMORY_LIMIT 2G
ENV PHP_ENABLE_XDEBUG false
ENV MAGENTO_ROOT /var/www/magento
ENV MAGENTO_RUN_MODE developer
ENV DEBUG false
ENV UPDATE_UID_GID false
RUN ["chmod", "+x", "/usr/local/bin/magento-installer"]
RUN ["chmod", "+x", "/usr/local/bin/magento-command"]
RUN ["chmod", "+x", "/usr/local/bin/magerun2"]
RUN ["chmod", "+x", "/usr/local/bin/run-cron"]

ENTRYPOINT ["/usr/local/bin/docker-environment"]
CMD ["php-fpm", "-F"]
CMD ["bash"]
Loading

0 comments on commit 5eee04b

Please sign in to comment.