From 9bd1e1002bf60da2c1630ab81861bd1b4850aa9e Mon Sep 17 00:00:00 2001 From: azgrey Date: Fri, 12 Jun 2026 08:26:49 +0700 Subject: [PATCH] docker edit --- Dockerfile | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4b54994..34729f4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,32 @@ +# ---- Stage 1: Build frontend (Vite/React) ---- +FROM node:20-alpine AS build + +WORKDIR /app + +# Install dependencies first (better layer caching) +COPY package*.json ./ +RUN npm install + +# Copy the rest of the source and build +COPY . . +RUN npm run build + +# ---- Stage 2: PHP + Apache to serve built files + api.php ---- FROM php:8.2-apache -# Enable Apache mod_rewrite +# Enable Apache mod_rewrite (useful for SPA routing) RUN a2enmod rewrite # Install MySQL PDO extension RUN docker-php-ext-install pdo pdo_mysql -# Copy project files to Apache web root -COPY . /var/www/html/ +# Copy built frontend assets from Stage 1 +COPY --from=build /app/dist/ /var/www/html/ + +# Copy api.php (and any other PHP backend files) into web root +COPY api.php /var/www/html/api.php # Set permissions RUN chown -R www-data:www-data /var/www/html -EXPOSE 80 +EXPOSE 80 \ No newline at end of file