in This Tutorial you will learn " How To Dockerizing Flask Application Using Docker on Ubuntu 20.04"
Flask is a popular Python web framework.
Docker is a software platform that allows you to build, test, and deploy applications quickly.
_________________________________________________________________________________________
Server - Os: Ubuntu 20.04.3 LTS 64Bit | IP -192.168.1.80 |Hostname - ubuntu.example.com
_________________________________________________________________________________________
lsb_release -d ; hostname -I ; hostname ; docker-compose --version ; docker --version
mkdir -p /var/www/flask ; cd /var/www/flask ; mkdir -p app/static ; mkdir -p app/templates
nano app/__init__.py
from flask import Flask
app = Flask(__name__)
from app import views
nano app/views.py
from app import app
@app.route('/')
def home():
return "Dockerizing Flask Application Using Docker!"
nano uwsgi.ini
[uwsgi]
module = main
callable = app
master = true
nano main.py
from app import app
nano requirements.txt
Flask==1.1.2
cd /var/www/flask ; nano Dockerfile
FROM tiangolo/uwsgi-nginx-flask:python3.6-alpine3.7
RUN apk --update add bash nano
ENV STATIC_URL /static
ENV STATIC_PATH /var/www/app/static
COPY ./requirements.txt /var/www/requirements.txt
RUN pip install -r /var/www/requirements.txt
nano start.sh
#!/bin/bash
app="docker.test"
docker build -t ${app} .
docker run -d -p 56733:80 \
--name=${app} \
-v $PWD:/app ${app}
bash start.sh
docker ps ; netstat -tlpn
127.0.0.1:56733
_________________________________________________________________________________________
Tuesday, March 1, 2022
Dockerizing Flask Application Using Docker on Ubuntu 20.04
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment