-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathDockerfile
More file actions
69 lines (55 loc) · 1.59 KB
/
Copy pathDockerfile
File metadata and controls
69 lines (55 loc) · 1.59 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
# =========================
# Stage 1: Composer build
# =========================
FROM composer:2.6 AS vendor
WORKDIR /app
# Dependency files first (better cache)
COPY composer.json composer.lock ./
COPY database/ database/
RUN composer install \
--ignore-platform-reqs \
--no-interaction \
--no-plugins \
--no-scripts \
--no-dev \
--prefer-dist \
--optimize-autoloader
# =========================
# Stage 2: Runtime
# =========================
FROM php:8.2-fpm-alpine
WORKDIR /var/www/html
# System dependencies (minimal production-safe set)
RUN apk add --no-cache \
nginx \
supervisor \
unzip \
zip \
libpng-dev \
libjpeg-turbo-dev \
freetype-dev \
libzip-dev
# PHP extensions (Laravel core requirements)
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install \
pdo_mysql \
bcmath \
gd \
zip
# Copy application (optimized layering)
COPY . .
# Copy vendor from build stage
COPY --from=vendor /app/vendor/ vendor/
# Config files
COPY ./docker/nginx.conf /etc/nginx/nginx.conf
COPY ./docker/supervisor.conf /etc/supervisor/conf.d/supervisor.conf
# Laravel required directories + secure permissions
RUN mkdir -p storage bootstrap/cache \
&& chown -R www-data:www-data storage bootstrap/cache \
&& chmod -R 775 storage bootstrap/cache
# Ensure correct ownership for full app
RUN chown -R www-data:www-data /var/www/html
# Expose HTTP port
EXPOSE 80
# Start supervisor (manages nginx + php-fpm + workers)
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisor.conf"]