From 0e63f93d8513ae4550b468a4004c2bb65967be2f Mon Sep 17 00:00:00 2001 From: mm154nm Date: Sun, 4 Apr 2021 23:07:05 +0200 Subject: [PATCH] Readme edit --- z1/.env | 9 +++++++++ z1/README.md | 26 +++++++++++++++++++------- z1/start-app.sh | 28 ++++++++++++++++++++++++++++ z1/stop-and-remove-app.sh | 13 +++++++++++++ z1/stop-app.sh | 13 +++++++++++++ z1/web/requirements.txt | 2 +- 6 files changed, 83 insertions(+), 8 deletions(-) create mode 100644 z1/.env create mode 100755 z1/start-app.sh create mode 100755 z1/stop-and-remove-app.sh create mode 100755 z1/stop-app.sh diff --git a/z1/.env b/z1/.env new file mode 100644 index 0000000..e77eba5 --- /dev/null +++ b/z1/.env @@ -0,0 +1,9 @@ +# Add Environment Variables + +DEBUG=False +SECRET_KEY=5(15ds+i2+%ik6z&!yer+ga9m=e%jcqiz_5wszg)r-z!2--b2d +DB_NAME=postgres +DB_USER=postgres +DB_PASS=postgres +DB_SERVICE=postgres +DB_PORT=5432 \ No newline at end of file diff --git a/z1/README.md b/z1/README.md index f61f3dd..b47169b 100644 --- a/z1/README.md +++ b/z1/README.md @@ -1,11 +1,23 @@ -## Dockerizing Flask With Compose and Machine - From Localhost to the Cloud +Jednoducha message web aplikacia pouzivajuca Flask, Nginx a Postgres. -Featuring: +Nalsedoval som navod: https://realpython.com/dockerizing-flask-with-compose-and-machine-from-localhost-to-the-cloud/ -- Docker v18.09.2 -- Docker Compose v1.23.2 -- Docker Machine v0.16.1 +Aplikaciu spustime skriptom "start-app". -**Check out the awesome blog post here > https://realpython.com/blog/python/dockerizing-flask-with-compose-and-machine-from-localhost-to-the-cloud/** +Aplikaciu zastavime skriptom "stop-app" +Tento skript pouziva "docker stop", teda spravy poslane do aplikacie ktore sa ulozili do databazy budu dostupne aj po opatovnom spusteni aplikacie. Databaza teda bezi v perzistentom containeri. -Cheers! +Aplikaciu zastavime a kompletne odstranime skriptom "stop-and-remove-app". + +Sucasti: + +Postgres databaza + Bezi na porte 5432 + Buildnuta z oficialneho PostgreSQL imagu + +Nginx sluzba + Bezi na porte 80 + Pouzivana ako reverse proxy, presmerovanie trafiky bud do Flask aplikacie, alebo do statickych suborov + +Flask aplikacia + Bezi na exposnutom porte 8000 \ No newline at end of file diff --git a/z1/start-app.sh b/z1/start-app.sh new file mode 100755 index 0000000..4ed5f7d --- /dev/null +++ b/z1/start-app.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +#tento script pripravi a spusti vsetko, po jeho ukonceni je aplikacia beziaca a funkcna + +echo "Starting setup" + +docker-machine create -d virtualbox dev; +docker-compose up --build -d +docker-compose run web /usr/local/bin/python create_db.py + + +echo "Setup and install finished" +echo "Looking for web app IP" +echo "-" +echo "--" +echo "---" +echo "----" +echo "-----" +echo "------" +echo "-------" +echo "--------" +echo "---------" +echo "----------" +echo "-----------" +echo "------------" +echo "Go to port 8000 of this address:" + +docker inspect z1_web_1 | grep "IPAddress" diff --git a/z1/stop-and-remove-app.sh b/z1/stop-and-remove-app.sh new file mode 100755 index 0000000..c85426d --- /dev/null +++ b/z1/stop-and-remove-app.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +#tento script zastavi beziace containery a vymaze ich + + +docker stop z1_nginx_1 && docker rm -f z1_nginx_1 +echo "Nginx odstraneny" +docker stop z1_web_1 && docker rm -f z1_web_1 +echo "Web odstraneny" +docker stop z1_postgres_1 && docker rm -f z1_postgres_1 +echo "Postgres odstraneny" +echo "------------" +echo "Aplikacia zastavena a prostredie vycistene " \ No newline at end of file diff --git a/z1/stop-app.sh b/z1/stop-app.sh new file mode 100755 index 0000000..245d469 --- /dev/null +++ b/z1/stop-app.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +#tento script zastavi beziace containery ALE nevymaze ich + + +docker stop z1_nginx_1 +echo "Nginx zastaveny" +docker stop z1_web_1 +echo "Web zastaveny" +docker stop z1_postgres_1 +echo "Postgres zastaveny" +echo "------------" +echo "Aplikacia zastavena" \ No newline at end of file diff --git a/z1/web/requirements.txt b/z1/web/requirements.txt index b2a33f2..d7caa69 100644 --- a/z1/web/requirements.txt +++ b/z1/web/requirements.txt @@ -6,4 +6,4 @@ SQLAlchemy==1.3.1 Werkzeug==0.15.1 gunicorn==19.9.0 itsdangerous==1.1.0 -psycopg2==2.7.7 +psycopg2==2.7.7 \ No newline at end of file