This commit is contained in:
Jp
2026-02-26 13:39:45 +08:00
parent 3c251e9c3a
commit 8b23298196

View File

@@ -1,11 +1,9 @@
FROM docker.io/php:8.4-fpm-alpine FROM docker.io/alpine:3.21
WORKDIR /var/www # Install PHP 8.4 and common extensions from Alpine community repos
# We use the community repository to get pre-compiled PHP 8.4 extensions
# This skips the source-code extraction that is causing your permission errors
RUN apk add --no-cache \ RUN apk add --no-cache \
php84-pecl-msgpack \ php84 \
php84-fpm \
php84-pdo_mysql \ php84-pdo_mysql \
php84-mbstring \ php84-mbstring \
php84-exif \ php84-exif \
@@ -14,22 +12,27 @@ RUN apk add --no-cache \
php84-gd \ php84-gd \
php84-zip \ php84-zip \
php84-intl \ php84-intl \
icu-data-full php84-curl \
php84-tokenizer \
php84-xml \
php84-xmlwriter \
php84-session \
curl
# Symlink the extensions so PHP can find them (Alpine puts them in a different path) # Create a symlink so 'php' command works
RUN ln -s /usr/lib/php84/modules/*.so /usr/local/lib/php/extensions/no-debug-non-zts-20240924/ RUN ln -sf /usr/bin/php84 /usr/bin/php
# Get latest Composer WORKDIR /var/www
# Get Composer
COPY --from=docker.io/composer:latest /usr/bin/composer /usr/bin/composer COPY --from=docker.io/composer:latest /usr/bin/composer /usr/bin/composer
# Copy application files # Copy only the application files
# The .dockerignore will prevent it from touching restricted system folders
COPY . /var/www COPY . /var/www
# Permission fix: Use a single RUN to reduce layer complexity # Laravel permission fix
RUN chown -R www-data:www-data /var/www && \ RUN chmod -R 775 /var/www/storage /var/www/bootstrap/cache
chmod -R 775 /var/www/storage /var/www/bootstrap/cache
USER www-data
EXPOSE 8000 EXPOSE 8000