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.
Docker packages an application and its dependencies into a container, ensuring it runs identically across all environments (dev, staging, production).
Frontend devs should know:
- Multi-stage Dockerfile — stage 1 builds the app, stage 2 copies only the build output into nginx/node, shrinking the image from 1GB to ~100MB.
- docker-compose.yml to run frontend + backend + database together with
docker-compose up. - .dockerignore to exclude
node_modulesand.nextto avoid copying unnecessary files
Critical note: environment variables must be injected at runtime (docker run -e), not hardcoded into the image, since one image serves multiple environments.