-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
55 lines (41 loc) · 1.57 KB
/
Dockerfile
File metadata and controls
55 lines (41 loc) · 1.57 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
47
48
49
50
51
52
53
54
55
# Use PHP 8.5 with Apache
FROM php:8.5-apache
# Set working directory
WORKDIR /var/www/html
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
unzip \
libzip-dev \
curl \
&& docker-php-ext-install zip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Enable Apache modules
RUN a2enmod rewrite headers
# Set ServerName to suppress FQDN warning
RUN echo "ServerName github-php-compatibility-checker" >> /etc/apache2/apache2.conf
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Copy composer files first for better layer caching
COPY composer.json composer.lock ./
# Install PHP dependencies
RUN composer install --no-dev --no-scripts --no-autoloader --prefer-dist
# Copy application files
COPY . .
# Complete Composer installation
RUN composer dump-autoload --optimize --no-dev
# Configure Apache DocumentRoot to public directory
ENV APACHE_DOCUMENT_ROOT=/var/www/html/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
# Set proper permissions
RUN chown -R www-data:www-data /var/www/html \
&& chmod -R 755 /var/www/html
# Expose port 80
EXPOSE 80
# Health check to verify Apache is responding with valid content
HEALTHCHECK --interval=60s --timeout=3s --start-period=5s --retries=3 \
CMD curl --fail-with-body -s http://localhost/ | grep -q "GitHub.*PHP.*Compatibility" || exit 1
# Start Apache
CMD ["apache2-foreground"]