docker-laravel-stack/docker/Dockerfile.php
2025-10-31 11:29:14 -04:00

56 lines
1.5 KiB
PHP
Executable file

# =========================================================
# PHP-FPM 8.2 Dockerfile for Laravel development
# =========================================================
FROM php:8.2-fpm
# --- Optional: Pass proxy args from compose ---
ARG HTTP_PROXY
ARG HTTPS_PROXY
ENV http_proxy=${HTTP_PROXY}
ENV https_proxy=${HTTPS_PROXY}
ENV HTTP_PROXY=${HTTP_PROXY}
ENV HTTPS_PROXY=${HTTPS_PROXY}
ENV NO_PROXY=localhost,127.0.0.1
# --- Install required system packages and PHP extensions ---
RUN apt-get update && apt-get install -y \
libpng-dev \
libjpeg-dev \
libfreetype6-dev \
zip \
unzip \
git \
curl \
libonig-dev \
libxml2-dev \
libzip-dev \
vim \
nano \
supervisor \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install gd pdo_mysql mbstring zip exif pcntl bcmath opcache \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# --- Install Composer globally ---
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# --- Optional: Install Node.js for Laravel Mix/Vite ---
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y nodejs \
&& npm install -g npm@latest
# --- Set working directory ---
WORKDIR /var/www/app
# --- Permissions: match host UID/GID if passed via docker-compose ---
ARG UID
ARG GID
RUN if [ -n "$UID" ] && [ -n "$GID" ]; then \
usermod -u $UID www-data && groupmod -g $GID www-data; \
fi
USER www-data
# --- Default command ---
CMD ["php-fpm"]