From dd188724be73252b93c64345922f70925ecfbdf9 Mon Sep 17 00:00:00 2001 From: Jp Date: Wed, 25 Feb 2026 22:34:05 +0800 Subject: [PATCH] build(docker): enhance Docker setup with proper dependencies and structure - Add comprehensive .dockerignore file to exclude unnecessary files - Update Dockerfile to install required system dependencies and PHP extensions - Set proper working directory and user permissions - Use multi-stage build for Composer installation --- .dockerignore | 19 +++++++++++++++++++ Dockerfile | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..0fc32aa --- /dev/null +++ b/.dockerignore @@ -0,0 +1,19 @@ +.git +.env +node_modules +vendor +storage/framework/cache/data/* +storage/framework/sessions/* +storage/framework/testing/* +storage/framework/views/* +storage/logs/* +public/storage +.phpunit.result.cache +.vscode +.idea +.devcontainer +docker-compose.yml +Dockerfile +.dockerignore +Makefile +k8s/ diff --git a/Dockerfile b/Dockerfile index f6cdc77..f37f0d7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,35 @@ FROM php:8.4-fpm -COPY . /app -WORKDIR /app +# Install system dependencies +RUN apt-get update && apt-get install -y \ + git \ + curl \ + libpng-dev \ + libonig-dev \ + libxml2-dev \ + zip \ + unzip \ + libzip-dev \ + libicu-dev +# Clear cache +RUN apt-get clean && rm -rf /var/lib/apt/lists/* + +# Install PHP extensions +RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd zip intl + +# Get latest Composer +COPY --from=composer:latest /usr/bin/composer /usr/bin/composer + +# Set working directory +WORKDIR /var/www + +# Copy existing application directory contents +COPY --chown=www-data:www-data . /var/www + +# Change current user to www +USER www-data + +# Expose port 8000 and start php-fpm server +EXPOSE 8000 CMD ["php", "artisan", "serve", "--host=0.0.0.0", "--port=8000"]