Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/meenaljy/multi-stage-project
This repo is for demonstrates the concept of Multistage build in Docker.
https://github.com/meenaljy/multi-stage-project
docker dockerfile
Last synced: 1 day ago
JSON representation
This repo is for demonstrates the concept of Multistage build in Docker.
- Host: GitHub
- URL: https://github.com/meenaljy/multi-stage-project
- Owner: MeenalJy
- Created: 2023-09-05T16:47:21.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-05T17:23:12.000Z (over 1 year ago)
- Last Synced: 2024-11-28T02:31:43.676Z (2 months ago)
- Topics: docker, dockerfile
- Language: Dockerfile
- Homepage:
- Size: 357 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Multistage Docker Build with Flask Web Application
This project demonstrates the concept of Multistage build in Docker using a Flask web application. It illustrates the difference in image size between a normal image build and a multi-stage image build.
## Table of Contents
- [Introduction](#introduction)
- [Prerequisites](#prerequisites)
- [Project Structure](#project-structure)
- [Usage](#usage)
- [Screenshots](#screenshots)
- [Dockerfile of Normal Image](#dockerfile-of-normal-image)
- [Dockerfile of Multi-stage Image](#dockerfile-of-multi-stage-image)
- [Size Difference](#size-difference)## Introduction
Docker is a powerful tool for containerization, and one of its features is multistage builds. Multistage builds allow us to create smaller, more efficient Docker images by separating the build environment from the runtime environment.
In this project, we demonstrate how to use multistage builds to create a Docker image for a Flask web application. We also compare the image size between a normal build and a multistage build to highlight the advantages of the latter.
## Prerequisites
Before you begin, ensure you have the following prerequisites:
- [Docker](https://www.docker.com/) installed on your system.
- Basic knowledge of Docker commands.## Project Structure
The project structure is as follows:
```
multistage-docker-flask/
├── app/
│ ├── app.py
│ ├── requirements.txt
├── Dockerfile
├── README.md
```- `app/`: Contains the Flask web application and its dependencies.
- `Dockerfile`: Defines the multistage Docker build.
- `README.md`: You're reading it!## Usage
1. Clone the repository:
```bash
git clone https://github.com/yourusername/multistage-docker-flask.git
cd multistage-docker-flask
```2. Build the Docker image using the multistage Dockerfile:
```bash
docker build -t multistage-flask-app .
```3. Run the Docker container:
```bash
docker run -p 5000:5000 multistage-flask-app
```4. Access the Flask web application in your browser at `http://localhost:5000`.
## Screenshots
### Dockerfile of Normal Image
![Dockerfile of Normal Image](screenshots/normal-dockerfile.jpg)
### Dockerfile of Multi-stage Image
![Dockerfile of Multi-stage Image](screenshots/mts-dockerfile.jpg)
### Size Difference
![Size Difference](screenshots/diff-of-size.jpg)