This project showcases how to optimize Docker images for a Hugo website (portfolio) using multi-stage builds. It highlights the benefits of smaller image sizes and streamlined deployments.
- Image size reduces from
424.01 MB
to55.25 MB
, for production environment that is a massive reduction of almost~88%
.
- Multi-Stage Efficiency: The
Dockerfile.prod
employs a multi-stage build process to separate development dependencies from the final, lean deployment image. - Hugo Compatibility: Designed specifically to work with the Hugo static site generator.
- Comparative Dockerfiles: Includes separate Dockerfiles (
Dockerfile.dev
andDockerfile.prod
) demonstrating the difference between development and optimized production builds
-
Clone the repository:
git clone https://github.com/[your-username]/hugo-portfolio-multistageDockerbuild.git
-
Build the optimized image (for production):
docker build -f Dockerfile.prod -t hugo-portfolio-prod:prod .
-
Run the container:
docker run -d -p 8080:80 hugo-portfolio:prod
-
Access your portfolio site at http://localhost:8080
- Dev Dockerfile: Provides a development environment, including Hugo tools.
- Prod Dockerfile (Multi-stage): Leverages a series of build steps to create a minimized image containing only the necessary runtime components.
This project is offered under the MIT license.