- Use php:8.4-fpm-alpine for smaller image size - Replace apt-get with apk package manager - Use docker-php-ext-install instead of external extension installer - Remove unnecessary comments and clean up cache appropriately
37 lines
808 B
Docker
37 lines
808 B
Docker
FROM php:8.4-fpm-alpine
|
|
|
|
WORKDIR /var/www
|
|
|
|
# Install system dependencies
|
|
RUN apk add --no-cache \
|
|
git \
|
|
curl \
|
|
libpng-dev \
|
|
oniguruma-dev \
|
|
libxml2-dev \
|
|
zip \
|
|
unzip \
|
|
libzip-dev \
|
|
icu-dev
|
|
|
|
# Install PHP extensions
|
|
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd zip intl
|
|
|
|
# Clear cache
|
|
RUN rm -rf /var/cache/apk/*
|
|
|
|
# Get latest Composer
|
|
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
|
|
|
# Copy application files and fix permissions
|
|
COPY . /var/www
|
|
RUN chown -R www-data:www-data /var/www && \
|
|
find /var/www -type d -exec chmod 755 {} + && \
|
|
find /var/www -type f -exec chmod 644 {} + && \
|
|
rm -rf /var/www/.circleci /var/www/.github
|
|
|
|
USER www-data
|
|
|
|
EXPOSE 8000
|
|
|
|
CMD ["php", "artisan", "serve", "--host=0.0.0.0", "--port=8000"] |