-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile.prod
More file actions
81 lines (67 loc) · 2.35 KB
/
Dockerfile.prod
File metadata and controls
81 lines (67 loc) · 2.35 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
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
# ===============================
# Stage 1: Build frontend assets
# ===============================
FROM node:20-alpine AS frontend
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
# ===============================
# Stage 2: Composer dependencies
# ===============================
FROM composer:2 AS vendor
WORKDIR /app
COPY composer.json composer.lock ./
# Ignore platform requirements during install for speed
RUN composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader --ignore-platform-reqs --no-scripts
# ===============================
# Stage 3: Runtime
# ===============================
FROM php:8.2-fpm-alpine
# Set working directory
WORKDIR /var/www/html
# Install Nginx, Supervisor, and required PHP extensions + OCR & PDF tools
RUN apk add --no-cache \
nginx \
supervisor \
bash \
git \
libpng-dev \
libjpeg-turbo-dev \
libzip-dev \
tesseract-ocr \
tesseract-ocr-data-ara \
tesseract-ocr-data-eng \
poppler-utils \
imagemagick \
autoconf \
g++ \
make \
linux-headers \
&& docker-php-ext-install pdo_mysql zip gd opcache \
&& pecl install redis \
&& docker-php-ext-enable redis \
&& apk del autoconf g++ make linux-headers
# Configure PHP for production
RUN echo "opcache.enable=1" >> /usr/local/etc/php/conf.d/opcache.ini \
&& echo "opcache.memory_consumption=256" >> /usr/local/etc/php/conf.d/opcache.ini \
&& echo "opcache.max_accelerated_files=20000" >> /usr/local/etc/php/conf.d/opcache.ini \
&& echo "opcache.validate_timestamps=0" >> /usr/local/etc/php/conf.d/opcache.ini
# Create directories
RUN mkdir -p /run/nginx
# Copy app code
COPY --chown=www-data:www-data . .
# Copy vendor from Stage 2
COPY --chown=www-data:www-data --from=vendor /app/vendor ./vendor
# Copy frontend build from Stage 1
COPY --chown=www-data:www-data --from=frontend /app/public/build ./public/build
RUN chmod -R 775 /var/www/html/storage /var/www/html/bootstrap/cache
# Copy Nginx configuration
COPY docker/nginx.conf /etc/nginx/nginx.conf
# Copy Supervisor configuration
COPY docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Expose port 80 (since Nginx runs on port 80 now)
EXPOSE 80
# Start Supervisord which manages Nginx, PHP-FPM, and Queue Worker
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]