docker edit

This commit is contained in:
azgrey
2026-06-12 08:26:49 +07:00
parent bd1be07542
commit 9bd1e1002b
+21 -4
View File
@@ -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