1
+ # defined in docker-compose.yml, from docker-env.env
2
+ ARG RUNTIME_PHP_IMAGE
3
+
4
+ # Use the specified image as the base
5
+ FROM ${RUNTIME_PHP_IMAGE}
6
+
7
+ # create the log file and provide permission to the www-data user
8
+ RUN touch /tmp/xdebug.log && chown www-data:www-data /tmp/xdebug.log
9
+
10
+ # same thing for the PHP error log
11
+ RUN touch /var/log/php-errors.log && chown www-data:www-data /var/log/php-errors.log
12
+
13
+ # Update the packages
14
+ # Install system packages required for MongoDB extension
15
+ # 'mysql-client' so we can log into mysql from the PHP container with the command 'mysql -h mysql -u root -p' where mysql is the service name
16
+ # 'iputils-ping' to get the ping command
17
+ RUN apt-get update \
18
+ && apt-get install -y libssl-dev wget git unzip default-mysql-client iputils-ping
19
+
20
+ RUN pecl apt update \
21
+ && apt install libzip-dev -y \
22
+ && docker-php-ext-install zip \
23
+ && rm -rf /var/lib/apt/lists/*
24
+
25
+ # Required for MySQL to work in PHP
26
+ RUN docker-php-ext-install mysqli && \
27
+ docker-php-ext-install pdo_mysql
28
+
29
+ # Test if already installed and
30
+ # install the <latest> mongodb PHP extension
31
+ # RUN pecl install mongodb && docker-php-ext-enable mongodb
32
+ RUN bash -c '[[ -n "$(pecl list | grep mongodb)" ]]\
33
+ || (pecl install mongodb && docker-php-ext-enable mongodb)'
34
+
35
+ # Test if already installed and
36
+ # install and enable XDEBUG <latest>
37
+ # RUN pecl install xdebug && docker-php-ext-enable xdebug
38
+ RUN bash -c '[[ -n "$(pecl list | grep xdebug)" ]]\
39
+ || (pecl install xdebug && docker-php-ext-enable xdebug)'
40
+
41
+ # install Redis PHP driver
42
+ RUN pecl install -o -f redis \
43
+ && rm -rf /tmp/pear \
44
+ && docker-php-ext-enable redis \
45
+ && docker-php-ext-enable pdo_mysql
46
+
47
+ # Task: copy rep's PHP .ini files to be automatically parsed
48
+ #
49
+ # directory is related to the PHP service context
50
+ # dot NOT use ./filename.ext for root files
51
+ # use filename.ext
52
+ COPY docker-php.ini /usr/local/etc/php/conf.d/
53
+ COPY xdebug.ini /usr/local/etc/php/conf.d/
54
+
55
+ # Install Composer
56
+ # ----------------------------------------------------------
57
+ # download composer
58
+ RUN curl -sS https://getcomposer.org/installer | php
59
+ # copy composer to a place where it can be globally executed
60
+ RUN mv composer.phar /usr/local/bin/composer
61
+
62
+ # our repo is in var/www/htdoc
63
+ # COPY init_repo.sh /var/www/htdoc/
64
+
65
+ # Set the working directory in the container
66
+ WORKDIR /var/www/htdoc
67
+
68
+ # start out script that runs composer install, but ONLY if /vendor/ does not exist
69
+ # WARNING: the commands below crash CodeSpaces. Not using for now.
70
+ # RUN chmod +x /var/www/htdoc/init_repo.sh
71
+ # ENTRYPOINT ["/var/www/htdoc/init_repo.sh"]
0 commit comments