-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
38 lines (27 loc) · 1.13 KB
/
Dockerfile
File metadata and controls
38 lines (27 loc) · 1.13 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
# Use official PHP image with Apache
FROM php:8.2-apache
# Install required system packages and PHP extensions
RUN apt-get update && apt-get install -y \
git zip unzip libpq-dev libzip-dev && \
docker-php-ext-install pdo pdo_mysql zip
# Enable Apache mod_rewrite (needed for Laravel routes)
RUN a2enmod rewrite
# Set the Apache document root to Laravel's public directory
ENV APACHE_DOCUMENT_ROOT=/var/www/html/public
# Update the default Apache configuration file
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/000-default.conf \
&& sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf
# Copy project files into the container
COPY . /var/www/html/
# Set working directory
WORKDIR /var/www/html
# Install Composer
COPY --from=composer:2.6 /usr/bin/composer /usr/bin/composer
# Install dependencies
RUN composer install --no-dev --optimize-autoloader
# Set proper permissions for Laravel storage and cache
RUN chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache
# Expose web server port
EXPOSE 80
# Start Apache
CMD ["apache2-foreground"]