-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
116 lines (90 loc) · 2.75 KB
/
Dockerfile
File metadata and controls
116 lines (90 loc) · 2.75 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# Multi-stage Dockerfile for Re:do Laravel Application
# Stage 1: PHP base image with extensions
FROM php:8.2-fpm-alpine AS php-base
# Install system dependencies
RUN apk add --no-cache \
git \
curl \
libpng-dev \
libxml2-dev \
zip \
unzip \
oniguruma-dev \
icu-dev \
freetype-dev \
libjpeg-turbo-dev \
libzip-dev \
mysql-client \
supervisor \
nginx \
nodejs \
npm
# Install PHP extensions
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install \
pdo_mysql \
mbstring \
exif \
pcntl \
bcmath \
gd \
zip \
intl \
opcache
# Install Redis and pcov extensions
RUN apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \
&& pecl install redis pcov \
&& docker-php-ext-enable redis pcov \
&& apk del .build-deps
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Stage 2: Development image
FROM php-base AS development
# Set working directory
WORKDIR /var/www/html
# Copy PHP configuration
COPY docker/php/php.ini /usr/local/etc/php/conf.d/99-custom.ini
# Copy application files
COPY . .
# Install Composer dependencies
RUN composer install --no-dev --optimize-autoloader --no-interaction
# Install Node.js dependencies and build assets
RUN npm ci --only=production && npm run build
# Set permissions
RUN chown -R www-data:www-data /var/www/html \
&& chmod -R 755 /var/www/html/storage \
&& chmod -R 755 /var/www/html/bootstrap/cache
# Expose port
EXPOSE 9000
# Start PHP-FPM
CMD ["php-fpm"]
# Stage 3: Production image with Nginx
FROM php-base AS production
# Install additional production dependencies
RUN apk add --no-cache supervisor nginx
# Set working directory
WORKDIR /var/www/html
# Copy PHP and Nginx configurations
COPY docker/php/php.ini /usr/local/etc/php/conf.d/99-custom.ini
COPY docker/nginx/nginx.conf /etc/nginx/nginx.conf
COPY docker/supervisor/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Copy application files
COPY . .
# Install Composer dependencies
RUN composer install --no-dev --optimize-autoloader --no-interaction
# Install Node.js dependencies and build assets
RUN npm ci --only=production && npm run build
# Optimize Laravel for production
RUN php artisan config:cache \
&& php artisan route:cache \
&& php artisan view:cache
# Set permissions
RUN chown -R www-data:www-data /var/www/html \
&& chmod -R 755 /var/www/html/storage \
&& chmod -R 755 /var/www/html/bootstrap/cache
# Create nginx directories
RUN mkdir -p /var/log/nginx /var/cache/nginx /var/run
# Expose port
EXPOSE 80
# Start supervisor (manages nginx and php-fpm)
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]