-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathDockerfile
executable file
·68 lines (56 loc) · 1.84 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
# First stage: PHP with Apache
FROM php:8.2-apache AS php-apache
# Install system dependencies and PHP extensions
RUN apt-get update && \
apt-get install -y --no-install-recommends \
acl \
cron \
curl \
default-mysql-client \
gettext \
git \
libcurl4-openssl-dev \
libfreetype6-dev \
libicu-dev \
libjpeg62-turbo-dev \
libonig-dev \
libpng-dev \
libzip-dev \
openssl \
rsync \
unzip \
vim \
zip && \
apt-get upgrade -y openssl apache2 curl libxml2 && \
docker-php-ext-configure gd --with-freetype --with-jpeg && \
docker-php-ext-install pdo_mysql zip mysqli mbstring \
curl intl exif bcmath gd gettext && \
a2enmod rewrite headers deflate env && \
rm -rf /var/lib/apt/lists/*
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Copy custom PHP and Apache configuration
COPY ./docker/php-apache/custom-php.ini /usr/local/etc/php/conf.d/
COPY ./docker/php-apache/app.conf /etc/apache2/sites-enabled/000-default.conf
# Second stage: web server
FROM php-apache AS php-web
# Folder Permissions
RUN setfacl -R -m u:www-data:rwx /var/www/html && \
setfacl -dR -m u:www-data:rwx /var/www/html
# Set working directory
WORKDIR /var/www/html
# Switch to www-data user for web tasks
USER www-data
# Copy the application code to the container
COPY . .
# Install project dependencies using Composer
RUN composer install --no-dev --optimize-autoloader --no-progress && \
composer dump-autoload --optimize
# Use custom entrypoint script for the web server
COPY ./docker/entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
# Configure the cron job
COPY ./docker/php-apache/crontab /etc/cron.d/crontab
RUN chmod 0644 /etc/cron.d/crontab && \
crontab /etc/cron.d/crontab
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]