Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabian Derschatta committed Nov 17, 2024
2 parents 345c289 + 669b6ac commit cf7d07a
Show file tree
Hide file tree
Showing 31 changed files with 218 additions and 96 deletions.
3 changes: 3 additions & 0 deletions .env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ HOST_IP=host.docker.internal
# Available ngrok regions: us (Ohio), eu (Frankfurt), ap (Singapore), au (Sydney), sa (Sao Paulo), jp (Tokyo), in (Mumbai)
NGROK_REGION=au

# Set your preferred shell (used by things like tphp). bash and zsh are available.
INTERACTIVE_SHELL=zsh

# Build settings (this will have an affect on build only)
TIME_ZONE=Pacific/Auckland

Expand Down
2 changes: 1 addition & 1 deletion apache/config/server.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ RewriteCond %{HTTP_HOST} totara(\d)(\d)\.debug(:[0-9]+)?$
RewriteRule \.php - [H=proxy:fcgi://php-%1.%2-debug:9000]

# Handle if the site name is specified in the host, e.g. sitename.totara73
RewriteCond %{HTTP_HOST} ^(\w+)\.totara
RewriteCond %{HTTP_HOST} ^(.+)\.totara
RewriteRule ^(.*)$ - [E=SITENAME:%1]

# If the server directory exists, then rewrite it to use it
Expand Down
24 changes: 1 addition & 23 deletions bin/tbash
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
#!/bin/bash

# Standard boilerplate code for getting the paths and environment variables we need.
script_path="$( cd "$(dirname "$0")" ; pwd -P )"
project_path="$( cd $script_path && cd ..; pwd -P )"
export $(grep -E -v '^#' $project_path/.env | xargs)
sub_path="${PWD//$LOCAL_SRC/}"
remote_path="$REMOTE_SRC/$sub_path"

if [ ! -f "$local_path/version.php" ]; then
remote_path="$REMOTE_SRC"
Expand All @@ -17,21 +12,4 @@ if [[ -z "$container" ]]; then
container="php"
fi

# If just 'php' is specified, then dynamically work out which one to actually use based upon the site composer.json
if [[ "$container" == "php" ]]; then
if [[ ! -f "$local_path/version.php" ]]; then
echo "This command must be run from a Totara site directory if 'php' is specified for the container"
exit 1
fi
php_container=($(php "$project_path/bin/helpers/php_container.php" "$local_path"))
container=${php_container[0]}
echo -e "\x1B[2mUsing PHP Container: $container\x1B[0m"
fi

# If we are bashing into php/apache/nginx, then lets make the shell begin in the remote directory
extra_args=""
if [[ "$container" =~ "php" || "$container" =~ "nginx" || "$container" =~ "apache" ]]; then
extra_args="-w $remote_path"
fi

$script_path/tdocker exec $extra_args "$container" /bin/bash
$script_path/texec "$container" /bin/bash
4 changes: 1 addition & 3 deletions bin/tdocker
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ elif [[ "$USE_MUTAGEN" == "1" || -f "$project_path/.use-mutagen" ]]; then
files+=(
"compose/sync.yml"
)

printf "\e[1;33mWarning:\e[0m \033[0;33mBuilt-in Mutagen integration is deprecated and will be removed in a future version. Please use the new Docker Desktop extension: https://github.com/totara/totara-docker-dev/wiki/Mutagen\033[0m";
fi

for file in custom/*.yml; do
Expand All @@ -45,7 +43,7 @@ for file in custom/*.yaml; do
[[ -e "$file" ]] && files+=($file)
done;

command="docker-compose "
command="docker compose "
for file in "${files[@]}"; do
command+=" -f ${file}"
done
Expand Down
39 changes: 39 additions & 0 deletions bin/texec
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

# Standard boilerplate code for getting the paths and environment variables we need.
script_path="$( cd "$(dirname "$0")" ; pwd -P )"
project_path="$( cd $script_path && cd ..; pwd -P )"
export $(grep -E -v '^#' $project_path/.env | xargs)
sub_path="${PWD//$LOCAL_SRC/}"
remote_path="$REMOTE_SRC/$sub_path"
local_path="$LOCAL_SRC/$sub_path"

container="$1"
shift
if [[ -z "$container" ]]; then
echo "Container must be specified"
exit 1
fi

# If just 'php' is specified, then dynamically work out which one to actually use based upon the site composer.json
if [[ "$container" == "php" ]]; then
if [[ ! -f "$local_path/version.php" ]]; then
echo "This command must be run from a Totara site directory if 'php' is specified for the container"
exit 1
fi
php_container=($(php "$project_path/bin/helpers/php_container.php" "$local_path"))
container=${php_container[0]}
echo -e "\x1B[2mUsing PHP Container: $container\x1B[0m"
fi

# If we are bashing into php/apache/nginx, then lets make the shell begin in the remote directory
extra_args=""
if [[ "$container" =~ "php" || "$container" =~ "nginx" || "$container" =~ "apache" ]]; then
extra_args="-w $remote_path"
fi

# Quote command to be reused as shell input
command_str=$(printf " %q" "$@")

$script_path/tdocker exec $extra_args "$container" "$command_str"

18 changes: 18 additions & 0 deletions bin/tphp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

# Standard boilerplate code for getting the paths and environment variables we need.
script_path="$( cd "$(dirname "$0")" ; pwd -P )"
project_path="$( cd $script_path && cd ..; pwd -P )"
export $(grep -E -v '^#' $project_path/.env | xargs)

if [[ -z "$1" ]]; then
$script_path/texec php "${INTERACTIVE_SHELL:-zsh}"
else
# Quote command to be reused as shell input
command_str=$(printf " %q" "$@")
# Handle being called with a php script instead of a command
if [[ $1 == *.php ]]; then
command_str="php $command_str"
fi
$script_path/texec php bash -ic "$command_str"
fi
25 changes: 5 additions & 20 deletions bin/tzsh
Original file line number Diff line number Diff line change
@@ -1,31 +1,16 @@
#!/bin/bash

# Standard boilerplate code for getting the paths and environment variables we need.
script_path="$( cd "$(dirname "$0")" ; pwd -P )"
project_path="$( cd $script_path && cd ..; pwd -P )"
export $(grep -E -v '^#' $project_path/.env | xargs)
sub_path="${PWD//$LOCAL_SRC/}"
remote_path="$REMOTE_SRC/$sub_path"
local_path="$LOCAL_SRC/$sub_path"

if [ ! -f "$local_path/version.php" ]; then
remote_path="$REMOTE_SRC"
# If the container isn't specified, then we just default to the default php container.
container="$1"
if [[ -z "$container" ]]; then
container="php"
fi

container="$1"
if [[ ! "$container" =~ "php" ]]; then
echo "tzsh only supports php containers"
exit 1
fi

# If just 'php' is specified, then dynamically work out which one to actually use based upon the site composer.json
if [[ "$container" == "php" ]]; then
if [[ ! -f "$local_path/version.php" ]]; then
echo "This command must be run from a Totara site directory if 'php' is specified for the container"
exit 1
fi
php_container=($(php "$project_path/bin/helpers/php_container.php" "$local_path"))
container=${php_container[0]}
fi

$script_path/tdocker exec -w $remote_path "$container" /bin/zsh
$script_path/texec "$container" /bin/zsh
6 changes: 6 additions & 0 deletions compose/apache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ services:
- totara81
- totara81.behat
- totara81.behat.totaralms.com
- totara82
- totara82.behat
- totara82.behat.totaralms.com
- totara83
- totara83.behat
- totara83.behat.totaralms.com

volumes:
totara-data:
6 changes: 6 additions & 0 deletions compose/nginx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ services:
- totara81
- totara81.behat
- totara81.behat.totaralms.com
- totara82
- totara82.behat
- totara82.behat.totaralms.com
- totara83
- totara83.behat
- totara83.behat.totaralms.com

volumes:
totara-data:
32 changes: 26 additions & 6 deletions config.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@
// Ngrok uses a few different URLs, add if a new one is used
$ngrok_urls = [
'ngrok.io',
'ngrok-free.app'
'ngrok-free.app',
'ngrok.app',
];

// Depending on the Ngrok version its hostname is stored in different server vars
Expand Down Expand Up @@ -311,15 +312,34 @@
}
}

if ($DOCKER_DEV->major_version >= 10) {
if ($DOCKER_DEV->major_version > 18) {
// Behat config for Totara 19 and higher
$CFG->behat_profiles['default'] = array(
'browser' => 'chrome',
'wd_host' => "http://$DOCKER_DEV->behat_host:4444/wd/hub",
'capabilities' => array(
'extra_capabilities' => array(
'goog:chromeOptions' => array(
'args' => array(
'--disable-background-timer-throttling',
'--disable-backgrounding-occluded-windows'
),
'excludeSwitches' => array(
'enable-automation'
),
'prefs' => array(
'credentials_enable_service' => false,
),
)
)
)
);
} else if ($DOCKER_DEV->major_version >= 10) {
// Behat config for Totara 10+
$CFG->behat_profiles['default'] = array(
'browser' => 'chrome',
'wd_host' => "http://$DOCKER_DEV->behat_host:4444/wd/hub",
'capabilities' => array(
'browserName' => 'chrome',
'browserVersion' => '106.0',
'platform' => 'Linux',
'extra_capabilities' => array(
'chromeOptions' => array(
'args' => array(
Expand Down Expand Up @@ -362,7 +382,7 @@
'wd_host' => "http://$DOCKER_DEV->behat_host:4444/wd/hub",
'capabilities' => array(
'version' => '',
'platform' => 'LINUX'
'platform' => 'LINUX',
)
)
)
Expand Down
2 changes: 1 addition & 1 deletion custom/.gitkeep
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Add any .yml or .yaml files in this folder to add additional or override existing docker-compose configurations
# Add any .yml or .yaml files in this folder to add additional or override existing docker compose configurations
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
# please check the compose files in the 'compose' folder
# you should use the built in bin/ scripts to run commands as it makes your life easier
# otherwise you need to run something like:
# docker-compose -f docker-compose.yml -f compose/nginx.yml -f compose/pgsql.yml -f compose/php.yml up -d pgsql php-7.3
# docker compose -f docker-compose.yml -f compose/nginx.yml -f compose/pgsql.yml -f compose/php.yml up -d pgsql php-7.3

nodejs:
image: node:20
Expand Down
2 changes: 1 addition & 1 deletion php/base/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# Source each .sh file found in the /shell/ folder, always source the default_aliases.sh file first
echo 'if [[ -e "/root/custom_shell/default-aliases.sh" ]] then source "/root/custom_shell/default-aliases.sh"; fi' >> ~/.bashrc
echo 'if [[ -e "/root/custom_shell/default-aliases.sh" ]]; then source "/root/custom_shell/default-aliases.sh"; fi' >> ~/.bashrc
echo 'for f in /root/custom_shell/*.sh; do [[ "$f" != "/root/custom_shell/default-aliases.sh" && -e "$f" ]] && source "$f"; done;' >> ~/.bashrc
echo 'setopt +o nomatch' > ~/.zshrc
echo 'source ~/custom_shell/.zshrc' >> ~/.zshrc
Expand Down
2 changes: 1 addition & 1 deletion php/php56/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ COPY config/php.ini /usr/local/etc/php/php.ini
COPY config/fpm.conf /usr/local/etc/php-fpm.d/zz-totara.conf

# Source each .sh file found in the /shell/ folder, always source the default_aliases.sh file first
RUN echo 'if [[ -e "/root/custom_shell/default-aliases.sh" ]] then source "/root/custom_shell/default-aliases.sh"; fi' >> ~/.bashrc && \
RUN echo 'if [[ -e "/root/custom_shell/default-aliases.sh" ]]; then source "/root/custom_shell/default-aliases.sh"; fi' >> ~/.bashrc && \
echo 'for f in /root/custom_shell/*.sh; do [[ "$f" != "/root/custom_shell/default-aliases.sh" && -e "$f" ]] && source "$f"; done;' >> ~/.bashrc

# Have the option of using the oh my zsh shell.
Expand Down
2 changes: 1 addition & 1 deletion php/php70/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ COPY config/php.ini /usr/local/etc/php/
COPY config/fpm.conf /usr/local/etc/php-fpm.d/zz-totara.conf

# Source each .sh file found in the /shell/ folder, always source the default_aliases.sh file first
RUN echo 'if [[ -e "/root/custom_shell/default-aliases.sh" ]] then source "/root/custom_shell/default-aliases.sh"; fi' >> ~/.bashrc && \
RUN echo 'if [[ -e "/root/custom_shell/default-aliases.sh" ]]; then source "/root/custom_shell/default-aliases.sh"; fi' >> ~/.bashrc && \
echo 'for f in /root/custom_shell/*.sh; do [[ "$f" != "/root/custom_shell/default-aliases.sh" && -e "$f" ]] && source "$f"; done;' >> ~/.bashrc

# Have the option of using the oh my zsh shell.
Expand Down
10 changes: 8 additions & 2 deletions php/php71-debug/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
FROM totara/docker-dev-php71:latest

RUN pecl install -f xdebug-2.9.6 && docker-php-ext-enable xdebug.so
RUN pecl install -f xdebug-2.9.8 && docker-php-ext-enable xdebug.so
RUN pecl install -f pcov && docker-php-ext-enable pcov.so

RUN echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_autostart=0" >> /usr/local/etc/php/conf.d/xdebug.ini
&& echo "xdebug.remote_autostart=0" >> /usr/local/etc/php/conf.d/xdebug.ini

# Set some sensible defaults
RUN echo "pcov.enabled=1" >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini \
&& echo "pcov.exclude='~(vendor|tests|node_modules|.git|client|.scannerwork)~'" >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini \
&& echo "pcov.initial.memory=1073741824" >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini \
&& echo "pcov.initial.files=30000" >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini
2 changes: 1 addition & 1 deletion php/php71/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ COPY config/php.ini /usr/local/etc/php/
COPY config/fpm.conf /usr/local/etc/php-fpm.d/zz-totara.conf

# Source each .sh file found in the /shell/ folder, always source the default_aliases.sh file first
RUN echo 'if [[ -e "/root/custom_shell/default-aliases.sh" ]] then source "/root/custom_shell/default-aliases.sh"; fi' >> ~/.bashrc && \
RUN echo 'if [[ -e "/root/custom_shell/default-aliases.sh" ]]; then source "/root/custom_shell/default-aliases.sh"; fi' >> ~/.bashrc && \
echo 'for f in /root/custom_shell/*.sh; do [[ "$f" != "/root/custom_shell/default-aliases.sh" && -e "$f" ]] && source "$f"; done;' >> ~/.bashrc

# Have the option of using the oh my zsh shell.
Expand Down
8 changes: 7 additions & 1 deletion php/php72-debug/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
FROM totara/docker-dev-php72:latest

RUN pecl install -f xdebug-3.1.1 && docker-php-ext-enable xdebug.so
RUN pecl install -f xdebug-3.1.6 && docker-php-ext-enable xdebug.so
RUN pecl install -f pcov && docker-php-ext-enable pcov.so

RUN echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.start_with_request=trigger" >> /usr/local/etc/php/conf.d/xdebug.ini

# Set some sensible defaults
RUN echo "pcov.enabled=1" >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini \
&& echo "pcov.exclude='~(vendor|tests|node_modules|.git|client|.scannerwork)~'" >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini \
&& echo "pcov.initial.memory=1073741824" >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini \
&& echo "pcov.initial.files=30000" >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini
11 changes: 7 additions & 4 deletions php/php72/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,16 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
&& docker-php-ext-install -j$(nproc) gd \
&& rm -rf /var/lib/apt/lists/*

RUN git clone https://github.com/tideways/php-profiler-extension.git \
&& cd php-profiler-extension \
RUN git clone https://github.com/longxinH/xhprof.git ./xhprof \
&& cd xhprof \
&& git checkout v2.3.10 \
&& cd extension/ \
&& phpize \
&& ./configure \
&& make && make install

RUN echo "extension=tideways_xhprof.so" >> /usr/local/etc/php/conf.d/tideways_xhprof.ini
RUN echo "extension=xhprof.so" >> /usr/local/etc/php/conf.d/xhprof.ini \
&& echo "xhprof.output_dir = /tmp/xhprof" >> /usr/local/etc/php/conf.d/xhprof.ini

RUN pecl install -o -f redis \
&& rm -rf /tmp/pear \
Expand Down Expand Up @@ -113,7 +116,7 @@ COPY config/php.ini /usr/local/etc/php/
COPY config/fpm.conf /usr/local/etc/php-fpm.d/zz-totara.conf

# Source each .sh file found in the /shell/ folder, always source the default_aliases.sh file first
RUN echo 'if [[ -e "/root/custom_shell/default-aliases.sh" ]] then source "/root/custom_shell/default-aliases.sh"; fi' >> ~/.bashrc && \
RUN echo 'if [[ -e "/root/custom_shell/default-aliases.sh" ]]; then source "/root/custom_shell/default-aliases.sh"; fi' >> ~/.bashrc && \
echo 'for f in /root/custom_shell/*.sh; do [[ "$f" != "/root/custom_shell/default-aliases.sh" && -e "$f" ]] && source "$f"; done;' >> ~/.bashrc

# Have the option of using the oh my zsh shell.
Expand Down
8 changes: 7 additions & 1 deletion php/php73-debug/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
FROM totara/docker-dev-php73:latest

RUN pecl install -f xdebug-3.1.1 && docker-php-ext-enable xdebug.so
RUN pecl install -f xdebug-3.1.6 && docker-php-ext-enable xdebug.so
RUN pecl install -f pcov && docker-php-ext-enable pcov.so

RUN echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.start_with_request=trigger" >> /usr/local/etc/php/conf.d/xdebug.ini

# Set some sensible defaults
RUN echo "pcov.enabled=1" >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini \
&& echo "pcov.exclude='~(vendor|tests|node_modules|.git|client|.scannerwork)~'" >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini \
&& echo "pcov.initial.memory=1073741824" >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini \
&& echo "pcov.initial.files=30000" >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini
Loading

0 comments on commit cf7d07a

Please sign in to comment.