Skip to content

Commit 29b3534

Browse files
committed
fix docker file to make it work with apache
1 parent 3af96d1 commit 29b3534

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

Dockerfile

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,40 @@
11
# Use the official PHP lightweight image with Apache
2-
FROM php:9.2-apache
2+
FROM php:8.3-apache-bullseye
33

44
# Set working directory
55
WORKDIR /var/www/html
66

7-
# Copy project files
8-
COPY . .
9-
10-
# Install system dependencies
7+
# Install system dependencies for Laravel (GD, MySQL, etc.)
118
RUN apt-get update && apt-get install -y \
129
libpng-dev \
1310
libjpeg-dev \
1411
libfreetype6-dev \
1512
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
1613
&& docker-php-ext-install gd \
17-
&& docker-php-ext-install pdo pdo_mysql
14+
&& docker-php-ext-install pdo pdo_mysql \
15+
&& apt-get clean
16+
17+
# Enable mod_rewrite for Apache (required for Laravel's clean URLs)
18+
RUN a2enmod rewrite
19+
20+
# Configure Apache to allow overrides and access to the Laravel public directory
21+
COPY ./apache/000-default.conf /etc/apache2/sites-available/000-default.conf
22+
23+
# Set correct permissions for the Laravel files
24+
RUN chown -R www-data:www-data /var/www/html
25+
RUN chmod -R 755 /var/www/html
26+
27+
# Copy the project files into the container
28+
COPY . .
1829

1930
# Install Composer
2031
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
2132

22-
# Install PHP dependencies
33+
# Install PHP dependencies using Composer
2334
RUN composer install --no-interaction --prefer-dist --optimize-autoloader
2435

25-
# Expose port 80
36+
# Expose port 80 for the Apache server
2637
EXPOSE 80
2738

28-
# Set entrypoint
29-
CMD ["apache2-foreground"]
39+
# Set the command to start Apache in the foreground
40+
CMD ["apache2-foreground"]

docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ services:
66
context: .
77
dockerfile: Dockerfile
88
ports:
9-
- "80:80"
9+
- "8000:80"
1010
volumes:
1111
- .:/var/www/html
1212
env_file:

0 commit comments

Comments
 (0)