DONE: add cicd pipeline separate fe and be, test first on gitea

This commit is contained in:
ISMAIL MASSERAN
2026-06-30 10:28:48 +08:00
parent 00ee1b22ff
commit f38cd6810b
14 changed files with 374 additions and 219 deletions
+5 -36
View File
@@ -1,33 +1,3 @@
# Stage 0: Build Vue frontend assets with Node.js
FROM node:22 AS frontend-builder
WORKDIR /app/frontend
# Copy frontend package files
COPY fe/package*.json ./
COPY fe/pnpm-lock.yaml* ./
# Install pnpm and frontend dependencies (including dev dependencies for build)
RUN npm install -g pnpm
RUN pnpm install --frozen-lockfile
# Copy frontend source code
COPY fe/ ./
# Build TWO frontend bundles (path-based):
# - Production: served at /
# - Training: served at /training/
#
# This avoids runtime JS injection and allows training/prod UI differences
# while keeping a single backend image.
RUN pnpm run typecheck \
&& pnpm exec vite build --mode=production --base=/ --outDir dist-prod \
&& pnpm exec vite build --mode=training --base=/training/ --outDir dist-training
# Clean up dev dependencies to reduce image size
ENV CI=true
RUN pnpm prune --prod
# Stage 1: Build environment and Composer dependencies
FROM php:8.4-fpm AS builder
@@ -150,12 +120,6 @@ RUN echo '[www]' > /usr/local/etc/php-fpm.d/zzz-status.conf && \
# Copy the application code and dependencies from the build stage first
COPY --from=builder /var/www /var/www
# Copy the built Vue frontends from frontend-builder stage
# - Production frontend at /
COPY --from=frontend-builder /app/frontend/dist-prod /var/www/public/
# - Training frontend at /training/
COPY --from=frontend-builder /app/frontend/dist-training /var/www/public/training/
# Set working directory
WORKDIR /var/www
@@ -173,3 +137,8 @@ EXPOSE 80 9000
# Start supervisor which manages both Nginx and PHP-FPM
CMD ["supervisord", "-c", "/etc/supervisor/supervisord.conf"]
# CI: install dev dependencies and run PHPUnit (build fails if tests fail)
FROM builder AS backend-test
RUN composer install --no-interaction --prefer-dist --no-scripts \
&& ./vendor/bin/phpunit --no-coverage