Docker đóng gói ứng dụng và dependencies vào container, đảm bảo chạy giống nhau trên mọi máy (dev, staging, production).
Frontend dev cần biết:
- Dockerfile multi-stage — stage 1 build app, stage 2 chỉ copy file build sang nginx/node, giảm image từ 1GB xuống ~100MB.
- docker-compose.yml để chạy frontend + backend + database cùng lúc bằng
docker-compose up. - .dockerignore loại
node_modulesvà.nexttránh copy file thừa
Lưu ý quan trọng: environment variables phải inject lúc runtime (docker run -e), không hardcode vào image vì image dùng chung cho nhiều môi trường.