Skip to content

Commit

Permalink
feat(php): add new dolphin base images for php 7.2, 7.3, and 7.4 (#64)
Browse files Browse the repository at this point in the history
Co-authored-by: Mateus Dutra Dadalto <[email protected]>
  • Loading branch information
damienwebdev and MateusDadalto committed Aug 4, 2022
1 parent 8637597 commit db7a950
Show file tree
Hide file tree
Showing 15 changed files with 652 additions and 0 deletions.
28 changes: 28 additions & 0 deletions php/7.2/fpm-alpine-dolphin/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM graycore/magento-php:7.2-fpm-alpine

LABEL maintainer="[email protected]"

# Blackfire
ENV current_os=alpine
RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \
&& curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/$current_os/amd64/$version \
&& mkdir -p /tmp/blackfire \
&& tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \
&& mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so \
&& printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8707\n" > $PHP_INI_DIR/conf.d/blackfire.ini \
&& rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz

RUN apk add --no-cache \
openssh patch gnupg git pcre-dev ${PHPIZE_DEPS} \
&& pecl install xdebug-2.9.8 \
&& docker-php-ext-enable xdebug \
&& apk del pcre-dev ${PHPIZE_DEPS}


COPY conf/php.ini /usr/local/etc/php/

COPY bin /root/

RUN mkdir -p /var/www/html

WORKDIR /var/www/html
108 changes: 108 additions & 0 deletions php/7.2/fpm-alpine-dolphin/bin/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#!/bin/sh
set -e

SETUP_START=`date +%s`

# Set the project namespace.
project="$(dirname "$0")"

source $project/util/welcome.sh
source $project/util/get-domain.sh

PROJECT_DOMAIN=$(getProjectDomain)

if [ -f 'pub/index.php' ]; then
echo 'Magento Codebase Discovered, Skipping project creation...';
echo '---------------------------------------------------------';
welcomeMessage;
SETUP_END=`date +%s`
echo "Setup took: $((SETUP_END-SETUP_START)) seconds..."
exit 0;
elif [ "$COMPOSER_PROJECT_ENABLED" == true ]; then
composer create-project --no-install --repository-url=https://repo.magento.com/ $COMPOSER_PROJECT .

composer config --no-interaction allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
composer config --no-interaction allow-plugins.laminas/laminas-dependency-plugin true
composer config --no-interaction allow-plugins.magento/* true
else
git clone $GIT_REPO --depth=1 .;
fi

composer install

bin/magento setup:install \
--no-interaction \
--base-url=https://$PROJECT_DOMAIN \
--db-host=database \
--db-name=magento2 \
--db-user=magento2 \
--db-password=magento2 \
--admin-firstname=Magento \
--admin-lastname=User \
[email protected] \
--admin-user=$MAGENTO_ADMIN_USERNAME \
--admin-password=$MAGENTO_ADMIN_PASSWORD \
--backend-frontname=$MAGENTO_ADMIN_PATH \
--language=$MAGENTO_LANGUAGE \
--currency=$MAGENTO_CURRENCY \
--timezone=$MAGENTO_TIMEZONE \
--cleanup-database

bin/magento setup:config:set \
--no-interaction \
--cache-backend=redis \
--cache-backend-redis-server=cache \
--cache-backend-redis-db=0

bin/magento setup:config:set \
--no-interaction \
--page-cache=redis \
--page-cache-redis-server=fullpagecache \
--page-cache-redis-db=0

bin/magento setup:config:set \
--no-interaction \
--session-save=redis \
--session-save-redis-host=sessioncache \
--session-save-redis-db=0

bin/magento setup:config:set \
--no-interaction \
--amqp-host='message_queue' \
--amqp-port='5672' \
--amqp-user='guest' \
--amqp-password='guest'

bin/magento config:set web/url/redirect_to_base 0

bin/magento config:set web/seo/use_rewrites 1

if [ "$MAGENTO_SAMPLE_DATA" == "venia" ]; then
echo "Installing 'Venia' Sample Data...";
composer config --no-interaction --ansi repositories.venia-sample-data composer https://repo.magento.com
composer require --no-interaction --ansi magento/venia-sample-data:*

bin/magento setup:upgrade
elif [ "$MAGENTO_SAMPLE_DATA" == "luma" ]; then
echo "Installing 'Luma' Sample Data...";
composer suggests --all --list | grep "magento" | grep "sample-data" | xargs -i composer require {} --no-update
composer update
bin/magento setup:upgrade
else
echo "Skipping Sample Data Install...";
fi

bin/magento indexer:reindex

chown www-data:www-data var generated pub/static pub/media app/etc -R

find var generated pub/static pub/media app/etc -type f -exec chmod g+w {} +

find var generated pub/static pub/media app/etc -type d -exec chmod g+ws {} +

bin/magento deploy:mode:set developer

welcomeMessage;

SETUP_END=`date +%s`
echo "Setup took: $((SETUP_END-SETUP_START)) seconds..."
9 changes: 9 additions & 0 deletions php/7.2/fpm-alpine-dolphin/bin/util/get-domain.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function getProjectDomain {
if [ -z "$CODESPACE_NAME" ]; then
local __PROJECT_DOMAIN=$MAGENTO_DOMAIN
else
local __PROJECT_DOMAIN="$CODESPACE_NAME-443.githubpreview.dev"
fi

echo $__PROJECT_DOMAIN
}
15 changes: 15 additions & 0 deletions php/7.2/fpm-alpine-dolphin/bin/util/welcome.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function welcomeMessage() {
printf "\n* __ ___ ___ ___ __ "
printf "\n* / |/ /__ ____ ____ |_ |/ _ \___ ____/ /_____ ____ "
printf "\n* / /|_/ / _ \`/ _ \`/ -_) __// // / _ \/ __/ \'_/ -_) __/ "
printf "\n* /_/ /_/\_,_/\_, /\__/____/____/\___/\__/_/\_\\__/_/ "
printf "\n* /___/ "
printf "\n*---------------------------------"
printf "\n* Wake me, when you need me."
printf "\n*"
printf "\n* Visit your store in your browser at https://$PROJECT_DOMAIN"
printf "\n* You can access the Admin UI at https://$PROJECT_DOMAIN/$MAGENTO_ADMIN_PATH"
printf "\n* Username: $MAGENTO_ADMIN_USERNAME"
printf "\n* Password: $MAGENTO_ADMIN_PASSWORD"
printf "\n---------------------------------\n"
}
68 changes: 68 additions & 0 deletions php/7.2/fpm-alpine-dolphin/conf/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Stock PHP Settings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; This sets the maximum amount of memory in bytes that a script is allowed to allocate.
; This helps prevent poorly written scripts for eating up all available memory on a server.
; Note that to have no memory limit, set this directive to -1.
memory_limit = 4G

; This sets the maximum time in seconds a script is allowed to run before it is terminated by the parser.
; This helps prevent poorly written scripts from tying up the server.
; The default setting is 30. When running PHP from the command line the default setting is 0.
max_execution_time = 30

date.timezone = UTC

; The maximum size of an uploaded file. When an integer is used, the value is measured in bytes.
; Shorthand notation may also be used.
upload_max_filesize = 20M

; Sets max size of post data allowed. This setting also affects file upload. To upload large files,
; this value must be larger than upload_max_filesize. Generally speaking, memory_limit should be
; larger than post_max_size. When an integer is used, the value is measured in bytes. Shorthand notation may also be used.
post_max_size = 20M

; Whether to transparently compress pages. If this option is set to "On" in php.ini or the Apache configuration,
; pages are compressed if the browser sends an "Accept-Encoding: gzip" or "deflate" header.
; "Content-Encoding: gzip" (respectively "deflate") and "Vary: Accept-Encoding" headers are added to the output.
zlib.output_compression = On

display_errors = stderr
error_log = /dev/stderr
display_startup_errors = On
log_errors = On

; Where the sendmail program can be found, usually /usr/sbin/sendmail or /usr/lib/sendmail.
; configure does an honest attempt of locating this one for you and set a default,
; but if it fails, you can set it here.
sendmail_path = ${PHP_SENDMAIL_PATH}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Xdebug Settings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Selects the host where the debug client is running, you can either use a host name, IP address, or 'unix:///path/to/sock'
; for a Unix domain socket. This setting is ignored if xdebug.remote_connect_back is enabled.
xdebug.remote_host = ${XDEBUG_REMOTE_HOST}

; The port to which Xdebug tries to connect on the remote host. Port 9000 is the default for both Xdebug and the Command
; Line Debug Client. As many clients use this port number, it is best to leave this setting unchanged.
xdebug.remote_port= ${XDEBUG_REMOTE_PORT}

; This switch controls whether Xdebug should try to contact a debug client which is listening on the host and port as set
; with the settings xdebug.remote_host and xdebug.remote_port. If a connection can not be established the script will
; just continue as if this setting was 0.
xdebug.remote_enable = 1

; Normally you need to use a specific HTTP GET/POST variable to start remote debugging (see Step Debugging). When this
; setting is set to 1, Xdebug will always attempt to start a remote debugging session and try to connect to a client,
; even if the GET/POST/COOKIE variable was not present.
xdebug.remote_autostart = 1

; If this setting is set to false, then Xdebug will not set-up internal structures to allow code coverage.
; This speeds up Xdebug quite a bit, but of course, Code Coverage Analysis won't work.
xdebug.coverage_enable = 0

; If this setting is 1, then stacktraces will be shown by default on an error event. You can disable showing stacktraces
; from your code with xdebug_disable().
xdebug.default_enable = 0
25 changes: 25 additions & 0 deletions php/7.3/fpm-alpine-dolphin/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM graycore/magento-php:7.3-fpm-alpine

# Blackfire
ENV current_os=alpine
RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \
&& curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/$current_os/amd64/$version \
&& mkdir -p /tmp/blackfire \
&& tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \
&& mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so \
&& printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8707\n" > $PHP_INI_DIR/conf.d/blackfire.ini \
&& rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz

RUN apk add --no-cache \
openssh patch gnupg git pcre-dev ${PHPIZE_DEPS} \
&& pecl install xdebug \
&& docker-php-ext-enable xdebug \
&& apk del pcre-dev ${PHPIZE_DEPS}

COPY conf/php.ini /usr/local/etc/php/

COPY bin /root/

RUN mkdir -p /var/www/html

WORKDIR /var/www/html
108 changes: 108 additions & 0 deletions php/7.3/fpm-alpine-dolphin/bin/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#!/bin/sh
set -e

SETUP_START=`date +%s`

# Set the project namespace.
project="$(dirname "$0")"

source $project/util/welcome.sh
source $project/util/get-domain.sh

PROJECT_DOMAIN=$(getProjectDomain)

if [ -f 'pub/index.php' ]; then
echo 'Magento Codebase Discovered, Skipping project creation...';
echo '---------------------------------------------------------';
welcomeMessage;
SETUP_END=`date +%s`
echo "Setup took: $((SETUP_END-SETUP_START)) seconds..."
exit 0;
elif [ "$COMPOSER_PROJECT_ENABLED" == true ]; then
composer create-project --no-install --repository-url=https://repo.magento.com/ $COMPOSER_PROJECT .

composer config --no-interaction allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
composer config --no-interaction allow-plugins.laminas/laminas-dependency-plugin true
composer config --no-interaction allow-plugins.magento/* true
else
git clone $GIT_REPO --depth=1 .;
fi

composer install

bin/magento setup:install \
--no-interaction \
--base-url=https://$PROJECT_DOMAIN \
--db-host=database \
--db-name=magento2 \
--db-user=magento2 \
--db-password=magento2 \
--admin-firstname=Magento \
--admin-lastname=User \
[email protected] \
--admin-user=$MAGENTO_ADMIN_USERNAME \
--admin-password=$MAGENTO_ADMIN_PASSWORD \
--backend-frontname=$MAGENTO_ADMIN_PATH \
--language=$MAGENTO_LANGUAGE \
--currency=$MAGENTO_CURRENCY \
--timezone=$MAGENTO_TIMEZONE \
--cleanup-database

bin/magento setup:config:set \
--no-interaction \
--cache-backend=redis \
--cache-backend-redis-server=cache \
--cache-backend-redis-db=0

bin/magento setup:config:set \
--no-interaction \
--page-cache=redis \
--page-cache-redis-server=fullpagecache \
--page-cache-redis-db=0

bin/magento setup:config:set \
--no-interaction \
--session-save=redis \
--session-save-redis-host=sessioncache \
--session-save-redis-db=0

bin/magento setup:config:set \
--no-interaction \
--amqp-host='message_queue' \
--amqp-port='5672' \
--amqp-user='guest' \
--amqp-password='guest'

bin/magento config:set web/url/redirect_to_base 0

bin/magento config:set web/seo/use_rewrites 1

if [ "$MAGENTO_SAMPLE_DATA" == "venia" ]; then
echo "Installing 'Venia' Sample Data...";
composer config --no-interaction --ansi repositories.venia-sample-data composer https://repo.magento.com
composer require --no-interaction --ansi magento/venia-sample-data:*

bin/magento setup:upgrade
elif [ "$MAGENTO_SAMPLE_DATA" == "luma" ]; then
echo "Installing 'Luma' Sample Data...";
composer suggests --all --list | grep "magento" | grep "sample-data" | xargs -i composer require {} --no-update
composer update
bin/magento setup:upgrade
else
echo "Skipping Sample Data Install...";
fi

bin/magento indexer:reindex

chown www-data:www-data var generated pub/static pub/media app/etc -R

find var generated pub/static pub/media app/etc -type f -exec chmod g+w {} +

find var generated pub/static pub/media app/etc -type d -exec chmod g+ws {} +

bin/magento deploy:mode:set developer

welcomeMessage;

SETUP_END=`date +%s`
echo "Setup took: $((SETUP_END-SETUP_START)) seconds..."
9 changes: 9 additions & 0 deletions php/7.3/fpm-alpine-dolphin/bin/util/get-domain.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function getProjectDomain {
if [ -z "$CODESPACE_NAME" ]; then
local __PROJECT_DOMAIN=$MAGENTO_DOMAIN
else
local __PROJECT_DOMAIN="$CODESPACE_NAME-443.githubpreview.dev"
fi

echo $__PROJECT_DOMAIN
}
Loading

0 comments on commit db7a950

Please sign in to comment.