Fast Docker, Python, Flask deployment on Linux | Raspberry Pi Example

Publicado el: 24 enero 2024
en el canal de: Skill Collectors
257
9

Instructions for your copying and pasting pleasure:

1. Install Docker on Ubuntu
sudo apt update
sudo apt install docker.io
sudo systemctl start docker
sudo systemctl enable docker
docker --version # Verify installation

You will need to add your user to the Docker group, add the user with the command below and restart the shell session.
sudo usermod -aG docker insert-your-username-here

2. Create a Basic Flask App

Create a new directory and navigate into it:
mkdir flask_app && cd flask_app

Create app.py:
from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
return 'Hello, World!'

if _name_ == '__main__':
app.run(host='0.0.0.0', port=5000)


Create requirements.txt:
Flask

3. Dockerize the Flask App

Create a Dockerfile:
FROM python:3.8-slim

WORKDIR /app

COPY requirements.txt /app/
RUN pip install -r requirements.txt

COPY . /app

EXPOSE 5000

CMD ["python", "app.py"]

Build the Docker image:
docker build -t myflaskapp .

Run the container:
docker run -d -p 5000:5000 --restart=always myflaskapp


En esta página del sitio puede ver el video en línea Fast Docker, Python, Flask deployment on Linux | Raspberry Pi Example de Duración hora minuto segunda en buena calidad , que subió el usuario Skill Collectors 24 enero 2024, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 257 veces y le gustó 9 a los espectadores. Disfruta viendo!