Repository navigation
Expand file tree
/
Copy pathDockerfile.prod
More file actions
95 lines (80 loc) · 3.61 KB
/
Copy pathDockerfile.prod
File metadata and controls
95 lines (80 loc) · 3.61 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
FROM alpine:3.21
ENV COMPOSER_ALLOW_SUPERUSER=1 \
COMPOSER_NO_INTERACTION=1 \
NPM_CONFIG_AUDIT=false \
NPM_CONFIG_FUND=false
# ─── Runtime: PHP-FPM + Nginx + Supervisor + Node (build) ────────────────────
RUN apk add --no-cache \
php84 php84-fpm \
php84-bcmath \
php84-ctype \
php84-curl \
php84-dom \
php84-exif \
php84-fileinfo \
php84-gd \
php84-iconv \
php84-intl \
php84-mbstring \
php84-mysqli \
php84-opcache \
php84-openssl \
php84-pcntl \
php84-pdo \
php84-pdo_mysql \
php84-phar \
php84-posix \
php84-session \
php84-simplexml \
php84-sockets \
php84-tokenizer \
php84-xml \
php84-xmlreader \
php84-xmlwriter \
php84-zip \
nginx supervisor \
nodejs npm \
bash curl git unzip
RUN ln -sf /usr/bin/php84 /usr/bin/php \
&& ln -sf /usr/sbin/php-fpm84 /usr/sbin/php-fpm
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
WORKDIR /var/www/html
# ─── PHP dependencies ─────────────────────────────────────────────────────────
COPY composer.json composer.lock ./
RUN composer install --no-dev --optimize-autoloader --no-scripts --no-interaction
# ─── Node dependencies ────────────────────────────────────────────────────────
COPY package.json package-lock.json ./
RUN npm ci
# ─── Application code ─────────────────────────────────────────────────────────
COPY . .
# ─── Build assets (wayfinder needs PHP, Vite needs Node) ─────────────────────
RUN cp .env.example .env \
&& php artisan key:generate \
&& php artisan wayfinder:generate --no-interaction \
&& npm run build \
&& php artisan package:discover --ansi \
&& rm .env \
&& rm -rf node_modules
# ─── Nginx / PHP / Supervisor configuration ──────────────────────────────────
COPY docker/nginx/prod.conf /etc/nginx/http.d/default.conf
COPY docker/php/php.ini /etc/php84/conf.d/laravel.ini
COPY docker/php/opcache.ini /etc/php84/conf.d/opcache.ini
COPY docker/php/fpm.conf /etc/php84/php-fpm.d/www.conf
COPY docker/supervisor/supervisord.prod.conf /etc/supervisor/conf.d/supervisord.conf
# ─── Writable dirs ───────────────────────────────────────────────────────────
RUN mkdir -p \
storage/app/public \
storage/framework/cache/data \
storage/framework/sessions \
storage/framework/views \
storage/logs \
bootstrap/cache \
&& chown -R nobody:nobody storage bootstrap/cache
# ─── Entrypoint ──────────────────────────────────────────────────────────────
COPY docker/entrypoint.prod.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
EXPOSE 80
HEALTHCHECK --interval=30s --timeout=5s --start-period=40s --retries=3 \
CMD wget -qO- http://127.0.0.1/up || exit 1
ENTRYPOINT ["/entrypoint.sh"]
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]