Repository navigation
Expand file tree
/
Copy pathdevelopment.Dockerfile
More file actions
108 lines (91 loc) · 4.23 KB
/
Copy pathdevelopment.Dockerfile
File metadata and controls
108 lines (91 loc) · 4.23 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
FROM php:8.5.12-cli
# Add docker PHP extension installer
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
# Install PHP extensions
RUN chmod +x /usr/local/bin/install-php-extensions && \
install-php-extensions mbstring pdo_mysql pdo_sqlsrv zip exif pcntl gd memcached redis swoole opcache curl readline sqlite3 msgpack igbinary pcov sockets bcmath soap imagick ftp
# libheif arrives indirectly via imagick; upgrade it from trixie-security and fail the build if a cached layer keeps an older one
RUN apt-get update && \
apt-get install -y --only-upgrade $(dpkg-query -W -f='${binary:Package}\n' 'libheif*' | cut -d: -f1) && \
dpkg --compare-versions "$(dpkg-query -W -f='${Version}' libheif1)" ge 1.23.4 && \
rm -rf /var/lib/apt/lists/*
# Harden ImageMagick against malicious-image RCE (disable dangerous coders/delegates + resource caps)
COPY docker/imagemagick-policy.xml /tmp/imagemagick-policy.xml
RUN mkdir -p /etc/ImageMagick-7 && \
for d in /etc/ImageMagick-7 /etc/ImageMagick-6; do \
if [ -d "$d" ]; then cp /tmp/imagemagick-policy.xml "$d/policy.xml"; fi; \
done && \
rm -f /tmp/imagemagick-policy.xml
# Install additional dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libpng-dev \
libjpeg62-turbo-dev \
libfreetype6-dev \
locales \
zip \
jpegoptim \
optipng \
pngquant \
gifsicle \
unzip \
git \
curl \
lua-zlib-dev \
libmemcached-dev \
nginx \
vim \
xvfb \
ffmpeg \
fontconfig \
libxrender1 \
libxext6 \
xfonts-75dpi \
xfonts-base && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Install wkhtmltopdf from GitHub releases (not available in Debian Trixie repos)
RUN ARCH=$(dpkg --print-architecture) && \
if [ "$ARCH" = "arm64" ]; then \
curl -L -o /tmp/wkhtmltox.deb https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-3/wkhtmltox_0.12.6.1-3.bookworm_arm64.deb; \
else \
curl -L -o /tmp/wkhtmltox.deb https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-3/wkhtmltox_0.12.6.1-3.bookworm_amd64.deb; \
fi && \
dpkg -i /tmp/wkhtmltox.deb || apt-get install -f -y && \
rm /tmp/wkhtmltox.deb
# Install Node.js and chokidar for file watching
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
apt-get install -y nodejs && \
npm install -g chokidar-cli
# --chown here instead of a later `chown -R`/`chmod -R` over the tree: a recursive metadata change
# rewrites every file into a new layer, duplicating the whole app once per such RUN.
COPY --chown=www-data:www-data . /var/www/html/
WORKDIR /var/www/html/
# Install chokidar locally for Laravel Octane with debugging
RUN echo "Installing chokidar for Laravel Octane..." && \
npm init -y && \
npm install chokidar@^3.5.3 && \
echo "Verifying chokidar installation..." && \
ls -la node_modules/ | grep chokidar && \
node -e "console.log('chokidar version:', require('chokidar/package.json').version)" && \
echo "NODE_PATH: $NODE_PATH" && \
echo "Current directory: $(pwd)" && \
echo "node_modules exists: $(test -d node_modules && echo 'YES' || echo 'NO')"
# Install composer globally
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Copy configuration files
# COPY ./docker/unit.json /docker-entrypoint.d/
COPY docker/docker-php-ext-opcache-prod.ini /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini
COPY docker/php.ini /usr/local/etc/php/conf.d/zx-app-config.ini
# Set git safe directory
RUN git config --global --add safe.directory /var/www/html
# storage/ and bootstrap/cache/ are .dockerignored, so recreate the skeleton Laravel expects
RUN mkdir -p storage/app/public storage/framework/cache/data storage/framework/sessions storage/framework/views storage/logs bootstrap/cache && \
chown -R www-data:www-data storage bootstrap/cache node_modules && \
chmod -R 777 storage bootstrap/cache
# Install PHP dependencies
RUN composer install --no-dev --optimize-autoloader
# Expose the required port
EXPOSE 8000
# Keep container running without starting a web server
CMD ["tail", "-f", "/dev/null"]