Skip to content

Commit 25904b2

Browse files
authored
Merge pull request #163 from andrewnicols/streamline_build
Streamline the build of the image
2 parents a5411f6 + 251fea0 commit 25904b2

File tree

3 files changed

+42
-16
lines changed

3 files changed

+42
-16
lines changed

Dockerfile

+13-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ ARG TARGETPLATFORM
55
ENV TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64}
66
RUN echo "Building for ${TARGETPLATFORM}"
77

8-
ADD root/ /
9-
# Fix the original permissions of /tmp, the PHP default upload tmp dir.
10-
RUN chmod 777 /tmp && chmod +t /tmp
11-
128
# Install some packages that are useful within the images.
139
RUN apt-get update && apt-get install -y \
1410
git \
@@ -30,11 +26,24 @@ RUN apt-get update && apt-get install -y \
3026

3127
# Setup the required extensions.
3228
ARG DEBIAN_FRONTEND=noninteractive
29+
ADD root/tmp/setup/php-extensions.sh /tmp/setup/php-extensions.sh
3330
RUN /tmp/setup/php-extensions.sh
31+
32+
# Install Oracle Instantclient
33+
ADD root/tmp/setup/oci8-extension.sh /tmp/setup/oci8-extension.sh
3434
RUN /tmp/setup/oci8-extension.sh
3535
ENV LD_LIBRARY_PATH /usr/local/instantclient
3636

37+
# Install Microsoft sqlsrv.
38+
ADD root/tmp/setup/sqlsrv-extension.sh /tmp/setup/sqlsrv-extension.sh
39+
RUN /tmp/setup/sqlsrv-extension.sh
40+
3741
RUN mkdir /var/www/moodledata && chown www-data /var/www/moodledata && \
3842
mkdir /var/www/phpunitdata && chown www-data /var/www/phpunitdata && \
3943
mkdir /var/www/behatdata && chown www-data /var/www/behatdata && \
4044
mkdir /var/www/behatfaildumps && chown www-data /var/www/behatfaildumps
45+
46+
ADD root/usr /usr
47+
48+
# Fix the original permissions of /tmp, the PHP default upload tmp dir.
49+
RUN chmod 777 /tmp && chmod +t /tmp

root/tmp/setup/php-extensions.sh

+3-12
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ set -e
55
echo "Installing apt dependencies"
66

77
# Build packages will be added during the build, but will be removed at the end.
8-
BUILD_PACKAGES="gettext gnupg libcurl4-openssl-dev libfreetype6-dev libicu-dev libjpeg62-turbo-dev \
8+
BUILD_PACKAGES="gettext libcurl4-openssl-dev libfreetype6-dev libicu-dev libjpeg62-turbo-dev \
99
libldap2-dev libmariadb-dev libmemcached-dev libpng-dev libpq-dev libxml2-dev libxslt-dev \
10-
unixodbc-dev uuid-dev"
10+
uuid-dev"
1111

1212
# Packages for Postgres.
1313
PACKAGES_POSTGRES="libpq5"
@@ -17,7 +17,7 @@ PACKAGES_MYMARIA="libmariadb3"
1717

1818
# Packages for other Moodle runtime dependenices.
1919
PACKAGES_RUNTIME="ghostscript libaio1 libcurl4 libgss3 libicu67 libmcrypt-dev libxml2 libxslt1.1 \
20-
libzip-dev locales sassc unixodbc unzip zip"
20+
libzip-dev locales sassc unzip zip"
2121

2222
# Packages for Memcached.
2323
PACKAGES_MEMCACHED="libmemcached11 libmemcachedutil2"
@@ -74,15 +74,6 @@ echo "pcov.exclude='~\/(tests|coverage|vendor|node_modules)\/~'" >> /usr/local/e
7474
echo "pcov.directory=." >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini
7575
echo "pcov.initial.files=1024" >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini
7676

77-
# Install Microsoft dependencies for sqlsrv.
78-
# (kept apart for clarity, still need to be run here
79-
# before some build packages are deleted)
80-
if [[ ${TARGETPLATFORM} == "linux/amd64" ]]; then
81-
/tmp/setup/sqlsrv-extension.sh
82-
else
83-
echo "sqlsrv extension not available for ${TARGETPLATFORM} architecture, skipping"
84-
fi
85-
8677
# Keep our image size down..
8778
pecl clear-cache
8879
apt-get remove --purge -y $BUILD_PACKAGES

root/tmp/setup/sqlsrv-extension.sh

+26
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,25 @@
22

33
set -e
44

5+
if [[ ${TARGETPLATFORM} != "linux/amd64" ]]; then
6+
echo "sqlsrv extension not available for ${TARGETPLATFORM} architecture, skipping"
7+
exit 0
8+
fi
9+
10+
# Packages for build.
11+
BUILD_PACKAGES="gnupg unixodbc-dev"
12+
13+
# Packages for sqlsrv runtime.
14+
PACKAGES_SQLSRV="unixodbc"
15+
16+
# Note: These dependencies must be installed before installing the Microsoft source because there is a package in there
17+
# which breaks the install.
18+
echo "Installing apt dependencies"
19+
apt-get update
20+
apt-get install -y --no-install-recommends apt-transport-https \
21+
$BUILD_PACKAGES \
22+
$PACKAGES_SQLSRV
23+
524
# Install Microsoft dependencies for sqlsrv
625
echo "Downloading sqlsrv files"
726
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
@@ -17,3 +36,10 @@ ln -fsv /opt/mssql-tools/bin/* /usr/bin
1736
# Need 5.10.1 (or later) for PHP 8.2 support
1837
pecl install sqlsrv-5.10.1
1938
docker-php-ext-enable sqlsrv
39+
40+
# Keep our image size down..
41+
pecl clear-cache
42+
apt-get remove --purge -y $BUILD_PACKAGES
43+
apt-get autoremove -y
44+
apt-get clean
45+
rm -rf /var/lib/apt/lists/*

0 commit comments

Comments
 (0)