How mitate-gengaku/test-multistage-build works
Project type and purpose
• This is a learning‐oriented, full-stack Dockerized application demonstrating multi-stage builds for Node.js (Next.js) and PHP (Laravel).
• The root contains two main code bases—“app” (Next.js frontend) and “api” (Laravel backend)—plus a “container” folder with Dockerfiles and a docker-compose.yml orchestrating five services.
File structure
• Top-level directories:
• api: Laravel PHP MVC application (Controllers, Models, routes, config, migrations, resources, tests).
• app: Next.js + React + TypeScript front end (pages/app, globals.css, layout.tsx, tests, Tailwind).
• container: per-service Dockerfiles (api, app, cache, db, web).
• docker-compose.yml: defines services “api,” “app,” “cache,” “db,” “web,” plus networks/volumes.
• Architectural hints: clean separation of API and UI, container-per-service pattern, reverse-proxy via “web.”
Extract README insights
• Purpose: to practice multi-stage Docker builds for both Node.js and PHP.
a. Main components:
• Client / Browser
• web container (Nginx reverse proxy)
• app container (Next.js frontend)
• api container (Laravel backend)
• cache container (Redis)
• db container (MySQL or PostgreSQL)
• Shared Docker network & volumes for code and persistent data
b. Relationships and interactions:
• Browser → web (HTTP/HTTPS)
• web → app for frontend routes and SSR
• web → api for API calls (e.g. /api/*)
• api ↔ db for data persistence (SQL queries)
• api ↔ cache for session or query caching (Redis)
• app may also call api directly (client-side fetch)
c. Architectural patterns & principles:
• Microservices-style container separation
• Reverse-proxy layer (web) isolating public endpoints
• MVC within api (Controllers, Models, Views)
• SSR/SSG within app (Next.js)
• Multi-stage Docker builds for lean images
d. Key technologies:
• Docker & Docker Compose
• Nginx (web container)
• Node.js, Next.js, React, TypeScript, Tailwind CSS (app)
• PHP, Laravel, Composer, Blade templates (api)
• Redis (cache)
• MySQL/PostgreSQL (db)
• Volumes for code hot-reload (app, api) and database persistence
Detail without overcomplicating
• Five docker-compose services and their runtime relationships.
• Ports (e.g., 80/443 on web, 3000 on app, 8000 on api).
• Volume mounts (code live-reload, db data, cache data).