-
-
Notifications
You must be signed in to change notification settings - Fork 34
/
dockerfile
95 lines (74 loc) · 2.41 KB
/
dockerfile
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# First stage: Composer installation
FROM composer:latest as composer
# Set the working directory in the Composer container
WORKDIR /app
# Copy the composer.json and composer.lock files
COPY composer.json composer.lock ./
# Install dependencies
RUN composer install --no-scripts --no-autoloader
# Optimize the autoloader
RUN composer dump-autoload --optimize
# Second stage: Apache + PHP setup
FROM php:8.3.0-apache
# Set the working directory
WORKDIR /var/www/html
# Install system dependencies
RUN apt-get update \
&& apt-get install -y \
libpng-dev \
libjpeg-dev \
libonig-dev \
libxml2-dev \
libzip-dev \
zip \
unzip \
git \
default-mysql-client \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
# Install PHP extensions
&& docker-php-ext-install \
pdo_mysql \
mbstring \
exif \
pcntl \
bcmath \
intl \
zip \
# Configure and install GD
&& docker-php-ext-configure gd --with-jpeg \
&& docker-php-ext-install gd
# Install tzdata package
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata
# Enable Apache mod_rewrite for .htaccess support
RUN a2enmod rewrite
# Expose port 80
EXPOSE 80
# Copy the application source
COPY . /var/www/html
# Copy default files in /public/img so they can be copied if needed in entrypoint, also create volume
RUN mkdir /tmp/img \
&& cp /var/www/html/public/img/* /tmp/img
VOLUME ["/var/www/html/public/img"]
# Create volume for logs
VOLUME ["/var/www/html/app/logs"]
# Create volume for backups
VOLUME ["/var/www/html/public/backup"]
# Copy themes and create volume for themes
RUN mkdir /tmp/themes \
&& cp -r /var/www/html/public/themes/* /tmp/themes
VOLUME ["/var/www/html/public/themes"]
# Copy migration list and create volume for migrations
RUN mkdir /tmp/migrations \
&& cp /var/www/html/app/migrations/* /tmp/migrations
VOLUME ["/var/www/html/app/migrations"]
# Copy the PHP overrides
COPY ./99-php.ini /usr/local/etc/php/conf.d/
# Copy the Composer dependencies from the first stage
COPY --from=composer /app/vendor/ /var/www/html/vendor/
# Copy docker-entrypoint.sh into the container
COPY --chmod=555 docker-entrypoint.sh /usr/local/bin/
# Set the script as the entrypoint
ENTRYPOINT ["docker-entrypoint.sh"]
# Start Apache server (CMD)
CMD ["apache2-foreground"]