-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
103 lines (82 loc) · 2.54 KB
/
Dockerfile
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
FROM node:20-alpine AS node-builder
ARG PROXY
ENV http_proxy=$PROXY \
HTTP_PROXY=$PROXY \
https_proxy=$PROXY \
HTTPS_PROXY=$PROXY
# Configure npm to use proxy
RUN npm config set proxy $PROXY \
&& npm config set https-proxy $PROXY \
&& npm config set registry https://registry.npmjs.org/
# Set working directory
WORKDIR /app
# Add build essentials
RUN apk add --no-cache python3 make g++
# Copy package files
COPY package.json package-lock.json ./
# Copy all necessary config files
COPY resources/ ./resources/
COPY vite.config.js ./
COPY postcss.config.js ./
COPY tailwind.config.js ./
RUN set -eux; \
npm install --prefer-offline --no-audit --no-progress
# Build assets with explicit env
RUN NODE_ENV=production npm run build
# Stage 2: Install PHP dependencies with Composer
FROM composer:2 AS composer-builder
ARG PROXY
ENV http_proxy=$PROXY \
HTTP_PROXY=$PROXY \
https_proxy=$PROXY \
HTTPS_PROXY=$PROXY
WORKDIR /app
# Install required PHP extensions
RUN apk add --no-cache \
icu-dev \
&& docker-php-ext-configure intl \
&& docker-php-ext-install intl
# Copy composer files first
COPY composer.json composer.lock ./
# Copy the rest of the application before installing
COPY . .
# Install dependencies without running scripts
RUN composer install --no-dev --prefer-dist --no-interaction --no-progress --no-scripts
# Now run the post-install scripts
RUN composer run-script post-autoload-dump
# Stage 3: Production image
FROM php:8.3-fpm-alpine
ARG PROXY
ENV http_proxy=$PROXY \
HTTP_PROXY=$PROXY \
https_proxy=$PROXY \
HTTPS_PROXY=$PROXY
WORKDIR /var/www/html
# Install system dependencies
RUN apk update && apk add --no-cache \
git \
curl \
libpng-dev \
oniguruma-dev \
libxml2-dev \
zip \
unzip \
bash \
icu-dev
# Install PHP extensions
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd && \
docker-php-ext-configure intl && \
docker-php-ext-install intl
# Configure opcache
COPY docker/php/opcache.ini /usr/local/etc/php/conf.d/opcache.ini
# Copy application files
COPY --from=composer-builder /app /var/www/html
COPY --from=node-builder /app/public/build /var/www/html/public/build
RUN mkdir -p /var/www/html/storage/framework/{sessions,views,cache} \
&& mkdir -p /var/www/html/storage/logs \
&& chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache \
&& chmod -R 775 /var/www/html/storage /var/www/html/bootstrap/cache
VOLUME /var/www/html/storage
# Expose port and start PHP-FPM
EXPOSE 9000
CMD ["php-fpm"]