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
This commit is contained in:
Jp
2026-02-25 22:34:05 +08:00
parent 95301dc1d8
commit dd188724be
2 changed files with 50 additions and 2 deletions

19
.dockerignore Normal file
View File

@@ -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/

View File

@@ -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"]