-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
80 lines (65 loc) · 2.02 KB
/
Dockerfile
File metadata and controls
80 lines (65 loc) · 2.02 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
FROM php:8.4.4-fpm-alpine AS builder
# Install necessary build dependencies
RUN apk add --no-cache \
mysql-dev \
postgresql-dev \
libzip-dev \
unzip \
git \
openssl-dev \
brotli-dev \
autoconf \
automake \
make \
gcc \
g++ \
libc-dev \
pcre-dev \
$PHPIZE_DEPS
# Install PHP extensions
RUN docker-php-ext-install pdo_mysql pdo_pgsql zip \
&& docker-php-ext-configure pcntl --enable-pcntl \
&& docker-php-ext-install pcntl \
&& docker-php-ext-install opcache
# Install Swoole via PECL
RUN pecl install swoole \
&& docker-php-ext-enable swoole \
&& pecl install redis \
&& docker-php-ext-enable redis
FROM php:8.4.4-fpm-alpine AS production
# Install runtime dependencies (required for the extensions to work)
RUN apk add --no-cache \
mysql-client \
postgresql-client \
libzip \
git
# Copy PHP extensions from builder stage
COPY --from=builder /usr/local/lib/php/extensions/ /usr/local/lib/php/extensions/
COPY --from=builder /usr/local/etc/php/conf.d/ /usr/local/etc/php/conf.d/
# Copy php.ini with OPcache settings
COPY php.ini /usr/local/etc/php/conf.d/opcache.ini
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Set working directory
WORKDIR /var/www
# Copy composer files first for better caching
COPY composer.json composer.lock ./
# Install dependencies (this layer will be cached if composer files don't change)
# Install dependencies with production optimizations
RUN composer install \
--no-dev \
--no-scripts \
--no-interaction \
--optimize-autoloader \
--classmap-authoritative \
&& composer clear-cache
# Copy application files
COPY . .
# Set permissions
RUN chown -R www-data:www-data /var/www \
&& chmod -R 755 /var/www/storage \
&& chmod -R 755 /var/www/bootstrap/cache
# Expose Port
EXPOSE 8000
# Start Laravel Octane with Swoole
CMD sh -c "php artisan migrate --force && php artisan storage:link && php artisan octane:start --server=swoole --host=0.0.0.0 --port=8000"