File size: 1,739 Bytes
3231299
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Use the official PHP image with PHP 8.1
FROM php:8.1-apache

# Install necessary packages and PHP extensions
RUN apt-get update && apt-get install -y \
    wget \
    git \
    gnupg \
    lsb-release \
    apt-transport-https \
    ca-certificates \
    libpq-dev \
    libsqlite3-dev \
    zip \
    unzip \
    && docker-php-ext-install pgsql pdo_pgsql pdo_sqlite mysqli pdo_mysql

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

# Copy the Laravel project into the container
COPY ./php/ /var/www/html

# Ensure .env file is copied
COPY ./php/.env /var/www/html/.env

# Run composer update to ensure compatible versions of dependencies
RUN composer update --working-dir=/var/www/html --no-scripts

# Set Apache DocumentRoot to Laravel's public directory
RUN sed -i 's|/var/www/html|/var/www/html/public|' /etc/apache2/sites-available/000-default.conf

# Change Apache to listen on port 7860
RUN sed -i 's/Listen 80/Listen 7860/' /etc/apache2/ports.conf \
    && sed -i 's/:80/:7860/' /etc/apache2/sites-available/000-default.conf

# Set correct permissions for Laravel directories
RUN chown -R www-data:www-data /var/www/html \
    && find /var/www/html -type d -exec chmod 755 {} \; \
    && find /var/www/html -type f -exec chmod 644 {} \;

# Ensure the storage and cache directories have the correct permissions
RUN mkdir -p /var/www/html/storage \
    && mkdir -p /var/www/html/bootstrap/cache \
    && chown -R www-data:www-data /var/www/html/storage \
    && chown -R www-data:www-data /var/www/html/bootstrap/cache \
    && chmod -R 775 /var/www/html/storage \
    && chmod -R 775 /var/www/html/bootstrap/cache

# Expose the Apache port
EXPOSE 7860

# Start Apache
CMD ["apache2-foreground"]