-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile_php
58 lines (46 loc) · 1.91 KB
/
Dockerfile_php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Use the PHP 8.1 Apache base image
FROM php:8.1-apache
# # Set environment variables
ENV APACHE_DOCUMENT_ROOT=/app/public \
APACHE_SERVER_NAME=localhost\
COMPOSER_ALLOW_SUPERUSER=1 \
APP_URL=${APP_URL} \
DB_CONNECTION=${DB_CONNECTION} \
DB_HOST=${DB_HOST} \
DB_PORT=${DB_PORT} \
DB_DATABASE=${DB_DATABASE} \
DB_USERNAME=${DB_USERNAME} \
DB_PASSWORD=${DB_PASSWORD} \
TEST_DATABASE_URL=${TEST_DATABASE_URL} \
MAIL_DRIVER=${MAIL_DRIVER} \
MAIL_HOST=${MAIL_HOST} \
MAIL_PORT=${MAIL_PORT}
# Set working directory
WORKDIR /app
# Copy the composer.json file
COPY . /app
# Install additional dependencies and configure Apache
RUN apt-get update -y \
&& apt-get install -y git zip unzip libpng-dev libldap2-dev libzip-dev wait-for-it \
&& docker-php-ext-configure ldap --with-libdir="lib/$(gcc -dumpmachine)" \
&& docker-php-ext-install pdo_mysql gd ldap zip \
&& pecl install xdebug \
&& docker-php-ext-enable xdebug \
&& a2enmod rewrite \
&& sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf \
&& sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf \
&& echo "ServerName ${APACHE_SERVER_NAME}" >> /etc/apache2/apache2.conf
# Install Composer
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
&& php composer-setup.php \
&& mv composer.phar /usr/bin/composer \
&& php -r "unlink('composer-setup.php');"
# Use the default production configuration and update it as required
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" \
&& sed -i 's/memory_limit = 128M/memory_limit = 512M/g' "$PHP_INI_DIR/php.ini"
# Expose port 80 8080
EXPOSE ${PORT_80}
# Copy entrypoint script
COPY ./dev/docker/entrypoint.app.sh /app/dev/docker/entrypoint.app.sh
# Set entrypoint
ENTRYPOINT ["/app/dev/docker/entrypoint.app.sh"]