-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
72 lines (56 loc) · 1.76 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
# Use an official PHP runtime as a parent image
FROM php:8.2-fpm-alpine
# Install system dependencies
RUN apk update && apk add --no-cache \
freetype-dev \
libjpeg-turbo-dev \
libpng-dev \
libzip-dev \
libxml2-dev \
oniguruma-dev \
linux-headers \
supervisor \
$PHPIZE_DEPS
# Clear the APK cache
RUN rm -rf /var/cache/apk/*
# Set environment variables for Oniguruma
ENV ONIG_CFLAGS="-I/usr/include/oniguruma"
ENV ONIG_LIBS="-L/usr/lib/"
# Configure and install PHP extensions
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) \
pdo_mysql \
mbstring \
exif \
pcntl \
bcmath \
gd \
zip \
sockets \
opcache
# Install Composer
COPY --from=composer:2.2 /usr/bin/composer /usr/bin/composer
# Copy existing application directory contents
COPY . /var/www
# Copy existing application directory permissions
COPY --chown=www-data:www-data . /var/www
# Copy scripts
COPY ./deployment/bin/* /usr/local/bin
# Copy supervisor configuration file
COPY supervisord.conf /etc/supervisord.conf
# Make scripts executables
RUN chmod +x /usr/local/bin/reload-supervisor.sh
RUN chmod +x /usr/local/bin/cleanup.sh
# Set permissions for Laravel
RUN chown -R www-data:www-data /var/www/storage /var/www/bootstrap/cache
# Create a log file for the cron job
RUN touch /var/www/storage/logs/scheduler.log \
&& chmod 777 /var/www/storage/logs/scheduler.log
# Add the cron job to run the script at midnight
RUN echo "0 0 * * * /usr/local/bin/cleanup.sh >> /var/log/cleanup_script.log 2>&1" > /etc/crontabs/root
# Expose port 9000 and start PHP-FPM server
EXPOSE 9000
CMD ["php-fpm"]
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]
# Start the cron service
CMD ["crond", "-f"]