-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
executable file
·53 lines (43 loc) · 1.78 KB
/
Dockerfile
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
FROM php:8.2-apache
# Install system dependencies
RUN apt-get update && apt-get install -y \
libsqlite3-dev \
git \
unzip \
&& docker-php-ext-install pdo_sqlite
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Enable Apache modules
RUN a2enmod rewrite headers
# Configure Apache
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf \
&& echo "LogLevel debug" >> /etc/apache2/apache2.conf
# Configure PHP
RUN echo "display_errors = On" >> /usr/local/etc/php/php.ini-development \
&& echo "error_reporting = E_ALL" >> /usr/local/etc/php/php.ini-development \
&& echo "log_errors = On" >> /usr/local/etc/php/php.ini-development \
&& echo "error_log = /var/log/php_errors.log" >> /usr/local/etc/php/php.ini-development \
&& cp /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini
# Set working directory
WORKDIR /var/www/html
# Copy application files
COPY . /var/www/html/
# Install dependencies
RUN composer install --no-interaction --no-progress --prefer-dist
# Create required directories and set permissions
RUN mkdir -p /var/www/html/data /var/www/html/logs /var/log \
&& touch /var/log/php_errors.log \
&& chown -R www-data:www-data /var/www/html /var/log/php_errors.log \
&& chmod -R 755 /var/www/html \
&& chmod -R 777 /var/www/html/data /var/www/html/logs /var/log/php_errors.log
# Configure Apache virtual host
RUN echo '<VirtualHost *:80>\n\
DocumentRoot /var/www/html\n\
ErrorLog ${APACHE_LOG_DIR}/error.log\n\
CustomLog ${APACHE_LOG_DIR}/access.log combined\n\
<Directory /var/www/html>\n\
Options Indexes FollowSymLinks\n\
AllowOverride All\n\
Require all granted\n\
</Directory>\n\
</VirtualHost>' > /etc/apache2/sites-available/000-default.conf