-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
51 lines (39 loc) · 1.35 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
# Set the base image
FROM php:8.1-apache
# Install system dependencies, PHP extensions, and cron
RUN apt-get update && apt-get install -y \
curl \
libpng-dev \
libjpeg-dev \
libfreetype6-dev \
libzip-dev \
unzip \
git \
cron \
nano \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install gd pdo pdo_mysql zip
# Install PHP extensions
COPY ./apache2.conf /etc/apache2/sites-available/000-default.conf
RUN a2ensite 000-default.conf
# Install Composer globally
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
# Set the working directory
WORKDIR /var/www/html
# Copy the existing application directory contents
COPY . /var/www/html
# Copy the application code
COPY . .
# Set permissions for the web directory
RUN chown -R www-data:www-data /var/www/html \
&& chmod -R 777 /var/www/html
# Install Composer dependencies
RUN composer install --no-interaction --optimize-autoloader
# Expose port 9000
EXPOSE 9000
# Add cron job to run Laravel scheduler
RUN echo "* * * * * cd /var/www && php artisan schedule:run >> /var/www/storage/logs/scheduler.log 2>&1" > /etc/cron.d/laravel-scheduler
# Apply cron job and start cron daemon
RUN chmod 0644 /etc/cron.d/laravel-scheduler && crontab /etc/cron.d/laravel-scheduler
# Start PHP-FPM and cron services
CMD service cron start && php-fpm