-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
52 lines (39 loc) · 1.53 KB
/
Dockerfile
File metadata and controls
52 lines (39 loc) · 1.53 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
# Use PHP with Apache as base image
FROM php:8.0-apache
# Install system dependencies
RUN apt-get update && apt-get install -y \
libcurl4-openssl-dev \
curl \
&& rm -rf /var/lib/apt/lists/*
# Install PHP extensions
RUN docker-php-ext-install curl
# Enable Apache mod_rewrite
RUN a2enmod rewrite
# Set working directory
WORKDIR /var/www/html
# Copy composer files first for better layer caching
#COPY app/composer.json app/composer.lock ./
# Install PHP dependencies if composer is available
# For now, we'll skip this since there are no dependencies beyond PHP
# RUN composer install --no-dev --optimize-autoloader
# Copy application source code
COPY app/ .
# Set proper permissions
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 {} \;
# Configure PHP (optional)
RUN echo "expose_php = Off" >> /usr/local/etc/php/conf.d/security.ini \
&& echo "display_errors = Off" >> /usr/local/etc/php/conf.d/security.ini \
&& echo "log_errors = On" >> /usr/local/etc/php/conf.d/security.ini
# Configure Apache (optional)
RUN echo "ServerTokens Prod" >> /etc/apache2/conf-available/security.conf \
&& echo "ServerSignature Off" >> /etc/apache2/conf-available/security.conf \
&& a2enconf security
# Health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
CMD curl -f http://localhost/index.php/healthcheck || exit 1
# Expose port 80
EXPOSE 80
# Start Apache in foreground
CMD ["apache2-foreground"]