-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
46 lines (35 loc) · 1.52 KB
/
Dockerfile
File metadata and controls
46 lines (35 loc) · 1.52 KB
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
FROM php:8.2-apache
# Install system dependencies
RUN apt-get update && apt-get install -y \
libpng-dev \
libjpeg-dev \
libfreetype6-dev \
zip \
unzip \
&& rm -rf /var/lib/apt/lists/*
# Install PHP extensions
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd pdo pdo_mysql mysqli
# Set document root to /var/www/html/src/public
ENV APACHE_DOCUMENT_ROOT /var/www/html/src/public
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
# Enable apache mod_rewrite
RUN a2enmod rewrite
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Copy composer files and install dependencies first for better caching
WORKDIR /var/www/html
COPY composer.json composer.lock .
RUN composer install --no-dev --optimize-autoloader
# Copy application files
COPY . .
# Move vendor folder to the correct location
RUN rm -rf src/private/vendor && mv vendor src/private
# Set permissions
RUN chown -R www-data:www-data /var/www/html/src/private/uploads
# Set permissions for all files (not just uploads)
RUN chown -R www-data:www-data /var/www/html
# Update Apache config to allow .htaccess and access to public
RUN echo '<Directory /var/www/html/src/public>\n AllowOverride All\n Require all granted\n</Directory>' > /etc/apache2/conf-available/allow-public.conf \
&& a2enconf allow-public