Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
__pycache__/
*.pyc
*.pyo
*.pyd
*.db
*.sqlite3
.env
.git
.gitignore
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use official lightweight Python image
FROM python:3.10-slim

# Set working directory
WORKDIR /app

# Copy requirements first (for caching)
COPY requirements.txt .

# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy all project files
COPY . .

# Expose Flask default port
EXPOSE 5000

# Run the Flask app
CMD ["python", "app.py"]
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,55 @@ For more basic knowledge of Flask, you can refer to [a tutorial on Tutorialspoin

- Step 3: Go to this app's directory and run `python app.py`

## How to Run (Docker way)
This app has been containerized using Docker. You can run it easily on any machine without worrying about dependencies.
## Prerequisites for Docker

Before running the app using Docker, make sure you have the following installed:

1. **Git** – to clone or fork the repository
- [Download Git](https://git-scm.com/downloads)

2. **Docker** – to build and run containers
- [Download Docker](https://www.docker.com/get-started)

3. **Docker Compose** – to run multi-container apps (usually comes with Docker Desktop)
- [Install Docker Compose](https://docs.docker.com/compose/install/)

### Steps to Run the App

1. **Clone or fork the repository:**
```bash
git clone https://github.com/your-username/your-repo.git

cd your-repo
```

2. **Build and start containers:**
```bash
docker-compose up -d
```
3. **Check running containers:**
```bash
docker ps
```
4. **Open the app in your browser:**
[runs on localhost:5000](http://localhost:5000)

5. **Stop containers:**
```bash
docker-compose down
```

## Benefits:

-Easy setup: No need to install Python or dependencies manually.

-Consistency: Same behavior across all environments (dev, staging, production).

-Portability: Can run anywhere Docker is available.

-Isolation: Dependencies are separated from the host machine.


## Details about This Toy App
Expand Down
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

services:
web:
build: .
container_name: flask-example
ports:
- "5000:5000"
volumes:
- .:/app
environment:
- FLASK_ENV=development
7 changes: 4 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Flask==1.1.2
Werkzeug==1.0.1
markupsafe==2.0.1
Flask==2.2.5
Werkzeug==2.2.3
markupsafe==2.1.1
Jinja2==3.1.2