diff --git a/Dockerfile b/Dockerfile index ad3d20a..8fb5a03 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,10 +5,6 @@ ARG TARGETPLATFORM ENV TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64} RUN echo "Building for ${TARGETPLATFORM}" -ADD root/ / -# Fix the original permissions of /tmp, the PHP default upload tmp dir. -RUN chmod 777 /tmp && chmod +t /tmp - # Install some packages that are useful within the images. RUN apt-get update && apt-get install -y \ git \ @@ -30,11 +26,24 @@ RUN apt-get update && apt-get install -y \ # Setup the required extensions. ARG DEBIAN_FRONTEND=noninteractive +ADD root/tmp/setup/php-extensions.sh /tmp/setup/php-extensions.sh RUN /tmp/setup/php-extensions.sh + +# Install Oracle Instantclient +ADD root/tmp/setup/oci8-extension.sh /tmp/setup/oci8-extension.sh RUN /tmp/setup/oci8-extension.sh ENV LD_LIBRARY_PATH /usr/local/instantclient +# Install Microsoft sqlsrv. +ADD root/tmp/setup/sqlsrv-extension.sh /tmp/setup/sqlsrv-extension.sh +RUN /tmp/setup/sqlsrv-extension.sh + RUN mkdir /var/www/moodledata && chown www-data /var/www/moodledata && \ mkdir /var/www/phpunitdata && chown www-data /var/www/phpunitdata && \ mkdir /var/www/behatdata && chown www-data /var/www/behatdata && \ mkdir /var/www/behatfaildumps && chown www-data /var/www/behatfaildumps + +ADD root/usr /usr + +# Fix the original permissions of /tmp, the PHP default upload tmp dir. +RUN chmod 777 /tmp && chmod +t /tmp diff --git a/root/tmp/setup/php-extensions.sh b/root/tmp/setup/php-extensions.sh index cf56e5d..9fca0fd 100755 --- a/root/tmp/setup/php-extensions.sh +++ b/root/tmp/setup/php-extensions.sh @@ -74,15 +74,6 @@ echo "pcov.exclude='~\/(tests|coverage|vendor|node_modules)\/~'" >> /usr/local/e echo "pcov.directory=." >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini echo "pcov.initial.files=1024" >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini -# Install Microsoft dependencies for sqlsrv. -# (kept apart for clarity, still need to be run here -# before some build packages are deleted) -if [[ ${TARGETPLATFORM} == "linux/amd64" ]]; then - /tmp/setup/sqlsrv-extension.sh -else - echo "sqlsrv extension not available for ${TARGETPLATFORM} architecture, skipping" -fi - # Keep our image size down.. pecl clear-cache apt-get remove --purge -y $BUILD_PACKAGES diff --git a/root/tmp/setup/sqlsrv-extension.sh b/root/tmp/setup/sqlsrv-extension.sh index 4911851..142d2a4 100755 --- a/root/tmp/setup/sqlsrv-extension.sh +++ b/root/tmp/setup/sqlsrv-extension.sh @@ -2,6 +2,23 @@ set -e +if [[ ${TARGETPLATFORM} != "linux/amd64" ]]; then + echo "sqlsrv extension not available for ${TARGETPLATFORM} architecture, skipping" + exit 0 +fi + +# Packages for build. +BUILD_PACKAGES="gnupg unixodbc-dev" + +# Packages for sqlsrv runtime. +PACKAGES_SQLSRV="" + +echo "Installing apt dependencies" +apt-get update +apt-get install -y --no-install-recommends apt-transport-https \ + $BUILD_PACKAGES \ + $PACKAGES_SQLSRV + # Install Microsoft dependencies for sqlsrv echo "Downloading sqlsrv files" curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - @@ -17,3 +34,10 @@ ln -fsv /opt/mssql-tools/bin/* /usr/bin # Need 5.10.1 (or later) for PHP 8.2 support pecl install sqlsrv-5.10.1 docker-php-ext-enable sqlsrv + +# Keep our image size down.. +pecl clear-cache +apt-get remove --purge -y $BUILD_PACKAGES +apt-get autoremove -y +apt-get clean +rm -rf /var/lib/apt/lists/*