docker edit

This commit is contained in:
azgrey
2026-06-12 08:26:49 +07:00
parent bd1be07542
commit 9bd1e1002b
+20 -3
View File
@@ -1,13 +1,30 @@
# ---- 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 FROM php:8.2-apache
# Enable Apache mod_rewrite # Enable Apache mod_rewrite (useful for SPA routing)
RUN a2enmod rewrite RUN a2enmod rewrite
# Install MySQL PDO extension # Install MySQL PDO extension
RUN docker-php-ext-install pdo pdo_mysql RUN docker-php-ext-install pdo pdo_mysql
# Copy project files to Apache web root # Copy built frontend assets from Stage 1
COPY . /var/www/html/ 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 # Set permissions
RUN chown -R www-data:www-data /var/www/html RUN chown -R www-data:www-data /var/www/html