Skip to content
This repository was archived by the owner on Jul 25, 2023. It is now read-only.

Commit 5e55413

Browse files
committed
Add Magento 2 services
1 parent 191456e commit 5e55413

17 files changed

+567
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/composer.env
2+
/magento

7.0-cli/Dockerfile

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#
2+
# Command line, PHP 7.0, Magento 2 compatible container.
3+
#
4+
# Credit to Mark Shust <[email protected]> for the basis of this
5+
# Dockerfile in the https://github.com/mageinferno/docker-magento2-php project.
6+
#
7+
8+
FROM php:7.0-cli
9+
10+
MAINTAINER Nick Jones <[email protected]>
11+
12+
# Install dependencies
13+
RUN apt-get update \
14+
&& apt-get install -y \
15+
cron \
16+
libfreetype6-dev \
17+
libicu-dev \
18+
libjpeg62-turbo-dev \
19+
libmcrypt-dev \
20+
libpng12-dev \
21+
libxslt1-dev
22+
23+
# Configure the gd library
24+
RUN docker-php-ext-configure \
25+
gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
26+
27+
# Install required PHP extensions
28+
RUN docker-php-ext-install \
29+
gd \
30+
intl \
31+
mbstring \
32+
mcrypt \
33+
pdo_mysql \
34+
xsl \
35+
zip
36+
37+
# Get composer installed to /usr/local/bin/composer
38+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
39+
40+
VOLUME /root/.composer/cache
41+
42+
ADD bin/* /usr/local/bin/
43+
ADD etc/php.ini /usr/local/etc/php/conf.d/zz-magento.ini
44+
45+
ENV PHP_MEMORY_LIMIT 2G
46+
ENV MAGENTO_ROOT /magento
47+
ENV COMPOSER_GITHUB_TOKEN ""
48+
ENV COMPOSER_MAGENTO_USERNAME ""
49+
ENV COMPOSER_MAGENTO_PASSWORD ""
50+
ENV DEBUG false
51+
ENV IS_OSX false
52+
53+
ENTRYPOINT ["/usr/local/bin/docker-environment"]
54+
55+
CMD ["bash"]

7.0-cli/bin/docker-environment

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
[ "$DEBUG" = "true" ] && set -x
4+
5+
# If we're using OSX then we need to mess with the permissions
6+
if [[ "$IS_OSX" = "true" ]]; then
7+
echo "OSX flag is set, changing www-data uid/gid"
8+
9+
usermod -u 501 www-data
10+
groupmod -g 9920 dialout # Move dialout from 20 to make room for www-data
11+
groupmod -g 20 www-data
12+
fi
13+
14+
# Ensure our Magento directory exists
15+
mkdir -p $MAGENTO_ROOT
16+
chown www-data:www-data $MAGENTO_ROOT
17+
18+
# Configure PHP
19+
[ ! -z "${PHP_MEMORY_LIMIT}" ] && sed -i "s/!PHP_MEMORY_LIMIT!/${PHP_MEMORY_LIMIT}/" /usr/local/etc/php/conf.d/zz-magento.ini
20+
21+
# Configure composer
22+
[ ! -z "${COMPOSER_GITHUB_TOKEN}" ] && \
23+
composer config --global github-oauth.github.com $COMPOSER_GITHUB_TOKEN
24+
25+
[ ! -z "${COMPOSER_MAGENTO_USERNAME}" ] && \
26+
composer config --global http-basic.repo.magento.com \
27+
$COMPOSER_MAGENTO_USERNAME $COMPOSER_MAGENTO_PASSWORD
28+
29+
exec "$@"

7.0-cli/bin/magento-command

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
[ "$DEBUG" = "true" ] && set -x
4+
5+
MAGENTO_COMMAND="$MAGENTO_ROOT/bin/magento"
6+
7+
chmod +x $MAGENTO_COMMAND
8+
su -c "$MAGENTO_COMMAND $*" -s /bin/bash www-data

7.0-cli/bin/magento-installer

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
3+
[ "$DEBUG" = "true" ] && set -x
4+
5+
# Get composer auth information into an environment variable to avoid "you need
6+
# to be using an interactive terminal to authenticate".
7+
COMPOSER_AUTH=`cat /root/.composer/auth.json`
8+
9+
composer --version
10+
11+
echo "Creating Magento ($M2SETUP_VERSION) project from composer"
12+
13+
composer create-project \
14+
--repository-url=https://repo.magento.com/ \
15+
magento/project-community-edition=$M2SETUP_VERSION \
16+
--no-interaction \
17+
$MAGENTO_ROOT
18+
19+
echo "Install Magento"
20+
21+
php /magento/bin/magento setup:install \
22+
--db-host=$M2SETUP_DB_HOST \
23+
--db-name=$M2SETUP_DB_NAME \
24+
--db-user=$M2SETUP_DB_USER \
25+
--db-password=$M2SETUP_DB_PASSWORD \
26+
--base-url=$M2SETUP_BASE_URL \
27+
--admin-firstname=$M2SETUP_ADMIN_FIRSTNAME \
28+
--admin-lastname=$M2SETUP_ADMIN_LASTNAME \
29+
--admin-email=$M2SETUP_ADMIN_EMAIL \
30+
--admin-user=$M2SETUP_ADMIN_USER \
31+
--admin-password=$M2SETUP_ADMIN_PASSWORD
32+
33+
php /magento/bin/magento index:reindex
34+
php /magento/bin/magento setup:static-content:deploy
35+
36+
echo "Fixing file permissions.."
37+
38+
sed -i 's/0770/0775/g' $MAGENTO_ROOT/vendor/magento/framework/Filesystem/DriverInterface.php
39+
sed -i 's/0660/0664/g' $MAGENTO_ROOT/vendor/magento/framework/Filesystem/DriverInterface.php
40+
41+
find $MAGENTO_ROOT/pub -type f -exec chmod 664 {} \;
42+
find $MAGENTO_ROOT/pub -type d -exec chmod 775 {} \;
43+
find $MAGENTO_ROOT/var/generation -type d -exec chmod g+s {} \;
44+
45+
chown -R www-data:www-data $MAGENTO_ROOT
46+
47+
echo "Installation complete"

7.0-cli/etc/php.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
; This file is created automatically by the docker build
2+
3+
memory_limit = !PHP_MEMORY_LIMIT! ; Variable: PHP_MEMORY_LIMIT

7.0-fpm/Dockerfile

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#
2+
# FPM, PHP 7.0, Magento 2 compatible container.
3+
#
4+
# Credit to Mark Shust <[email protected]> for the basis of this
5+
# Dockerfile in the https://github.com/mageinferno/docker-magento2-php project.
6+
#
7+
8+
FROM php:7.0-fpm
9+
10+
MAINTAINER Nick Jones <[email protected]>
11+
12+
# Install dependencies
13+
RUN apt-get update \
14+
&& apt-get install -y \
15+
cron \
16+
libfreetype6-dev \
17+
libicu-dev \
18+
libjpeg62-turbo-dev \
19+
libmcrypt-dev \
20+
libpng12-dev \
21+
libxslt1-dev
22+
23+
# Configure the gd library
24+
RUN docker-php-ext-configure \
25+
gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
26+
27+
# Install required PHP extensions
28+
RUN docker-php-ext-install \
29+
gd \
30+
intl \
31+
mbstring \
32+
mcrypt \
33+
pdo_mysql \
34+
xsl \
35+
zip
36+
37+
VOLUME /root/.composer/cache
38+
39+
ADD bin/docker-environment /usr/local/bin/
40+
ADD etc/php.ini /usr/local/etc/php/conf.d/zz-magento.ini
41+
ADD etc/php-fpm.conf /usr/local/etc/
42+
43+
ENV PHP_MEMORY_LIMIT 2G
44+
ENV MAGENTO_ROOT /magento
45+
ENV MAGENTO_RUN_MODE developer
46+
ENV DEBUG false
47+
ENV IS_OSX false
48+
49+
ENTRYPOINT ["/usr/local/bin/docker-environment"]
50+
CMD ["php-fpm", "-F"]

7.0-fpm/bin/docker-environment

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
[ "$DEBUG" = "true" ] && set -x
4+
5+
# If we're using OSX then we need to mess with the permissions
6+
if [[ "$IS_OSX" = "true" ]]; then
7+
echo "OSX flag is set, changing www-data uid/gid"
8+
9+
usermod -u 501 www-data
10+
groupmod -g 9920 dialout # Move dialout from 20 to make room for www-data
11+
groupmod -g 20 www-data
12+
fi
13+
14+
# Configure PHP
15+
[ ! -z "${PHP_MEMORY_LIMIT}" ] && sed -i "s/!PHP_MEMORY_LIMIT!/${PHP_MEMORY_LIMIT}/" /usr/local/etc/php/conf.d/zz-magento.ini
16+
17+
# Configure PHP-FPM
18+
[ ! -z "${MAGENTO_RUN_MODE}" ] && sed -i "s/!MAGENTO_RUN_MODE!/${MAGENTO_RUN_MODE}/" /usr/local/etc/php-fpm.conf
19+
20+
exec "$@"

7.0-fpm/etc/php-fpm.conf

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
; This file is created automatically by the docker build
2+
3+
[global]
4+
5+
error_log = /proc/self/fd/2
6+
daemonize = no
7+
8+
[www]
9+
10+
; if we send this to /proc/self/fd/1, it never appears
11+
access.log = /proc/self/fd/2
12+
13+
user = www-data
14+
group = www-data
15+
16+
listen = [::]:9000
17+
18+
pm = dynamic
19+
pm.max_children = 10
20+
pm.start_servers = 4
21+
pm.min_spare_servers = 2
22+
pm.max_spare_servers = 6
23+
24+
env[MAGE_MODE] = !MAGENTO_RUN_MODE!; # Variable: MAGENTO_RUN_MODE
25+
26+
clear_env = no
27+
28+
; Ensure worker stdout and stderr are sent to the main error log.
29+
catch_workers_output = yes

7.0-fpm/etc/php.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
; This file is created automatically by the docker build
2+
3+
memory_limit = !PHP_MEMORY_LIMIT! ; Variable: PHP_MEMORY_LIMIT

0 commit comments

Comments
 (0)