From 87fd5076181dfccc39c168479b3a2dce25daf759 Mon Sep 17 00:00:00 2001 From: Jp Date: Wed, 25 Feb 2026 22:52:20 +0800 Subject: [PATCH] chore(docker): move WORKDIR declaration earlier and reorder steps Set working directory before copying files to avoid potential conflicts with host files. Also reorder Dockerfile steps for better logical flow and maintainability. --- Dockerfile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 37a962c..646fb27 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,8 @@ FROM php:8.4-fpm +# Set working directory early to avoid conflicts with host files +WORKDIR /var/www + # Install system dependencies RUN apt-get update && apt-get install -y \ git \ @@ -24,15 +27,13 @@ RUN apt-get clean && rm -rf /var/lib/apt/lists/* # 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 application files 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 port 8000 EXPOSE 8000 + CMD ["php", "artisan", "serve", "--host=0.0.0.0", "--port=8000"]