-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
89 lines (72 loc) · 2.9 KB
/
Copy pathDockerfile
File metadata and controls
89 lines (72 loc) · 2.9 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
# Stage 1: Build assets
FROM node:20-alpine AS node-build
WORKDIR /app
# Install PHP and Composer for Tailwind CSS to scan vendor files (MaryUI components)
RUN apk add --no-cache php83 php83-phar php83-json php83-mbstring php83-openssl php83-curl php83-dom php83-tokenizer php83-xml php83-xmlwriter && \
ln -sf /usr/bin/php83 /usr/bin/php
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
php composer-setup.php --install-dir=/usr/local/bin --filename=composer && \
rm composer-setup.php
# Install Composer dependencies first (needed for Tailwind @source directives)
COPY composer.json composer.lock ./
RUN composer install --no-dev --no-scripts --ignore-platform-reqs --no-autoloader
# Install npm dependencies
COPY package*.json ./
RUN npm ci
# Copy source files for asset building
COPY resources ./resources
COPY vite.config.js ./
# Build assets (vendor/robsontenorio/mary now exists for Tailwind to scan)
RUN npm run build
# Stage 2: PHP dependencies
FROM composer:2 AS composer-build
WORKDIR /app
COPY composer.json composer.lock ./
RUN composer install --no-dev --optimize-autoloader --no-scripts --ignore-platform-reqs
COPY . .
RUN composer dump-autoload --optimize
# Stage 3: Production
FROM php:8.4-fpm
# System deps
RUN apt-get update && apt-get install -y --no-install-recommends \
nginx supervisor libzip-dev libpng-dev libjpeg-dev libfreetype6-dev \
libwebp-dev libonig-dev default-mysql-client ca-certificates \
$PHPIZE_DEPS \
&& docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp \
&& docker-php-ext-install pdo pdo_mysql mbstring zip exif pcntl bcmath gd fileinfo \
&& pecl install redis \
&& docker-php-ext-enable redis \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /var/www/html
# Copy built assets and vendor from build stages
COPY --from=composer-build /app/vendor ./vendor
COPY --from=node-build /app/public/build ./public/build
# Copy application code
COPY . .
# Ensure vendor icons are available
RUN php artisan vendor:publish --tag=mary-ui --force || true
# Permissions
RUN chown -R www-data:www-data storage bootstrap/cache
# Config files
COPY docker/nginx.conf /etc/nginx/sites-available/default
COPY docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY docker/uploads.ini /usr/local/etc/php/conf.d/uploads.ini
COPY docker/start.sh /start.sh
RUN chmod +x /start.sh
ENV APP_ENV=production
ENV APP_DEBUG=false
ENV LOG_CHANNEL=stderr
RUN { \
echo 'opcache.enable=1'; \
echo 'opcache.enable_cli=0'; \
echo 'opcache.memory_consumption=256'; \
echo 'opcache.interned_strings_buffer=32'; \
echo 'opcache.max_accelerated_files=20000'; \
echo 'opcache.validate_timestamps=0'; \
echo 'opcache.jit=tracing'; \
echo 'opcache.jit_buffer_size=64M'; \
echo 'realpath_cache_size=4096K'; \
echo 'realpath_cache_ttl=600'; \
} > /usr/local/etc/php/conf.d/opcache.ini
EXPOSE 80
CMD ["/start.sh"]