From ca33ca6b707dc881b27f08b9caa81e805c5c69a7 Mon Sep 17 00:00:00 2001 From: ThisBirchWood Date: Wed, 22 Jan 2025 00:55:18 +0000 Subject: [PATCH 1/2] Flask now runs on Gunicorn, and runs through NGinx --- docker-compose.yml | 7 ++++--- nginx/nginx.conf | 12 +++++++----- web_server/Dockerfile | 5 +---- .../__pycache__/database.cpython-311.pyc | Bin 2082 -> 0 bytes web_server/database/requirements.txt | 1 - web_server/requirements.txt | 1 + 6 files changed, 13 insertions(+), 13 deletions(-) delete mode 100644 web_server/database/__pycache__/database.cpython-311.pyc delete mode 100644 web_server/database/requirements.txt diff --git a/docker-compose.yml b/docker-compose.yml index d4c57b7..b55b87e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,13 +7,13 @@ services: - "1935:1935" # RTMP - "8080:8080" depends_on: - - flask + - app networks: - app_network - flask: + app: build: - context: ./web_server + context: ./app ports: - "5000:5000" networks: @@ -21,3 +21,4 @@ services: networks: app_network: + driver: bridge diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 029e39a..1548308 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -32,12 +32,14 @@ http { application/vnd.apple.mpegurl m3u8; video/mp2t ts; } + } - root /tmp; - add_header Cache-Control no-cache; - add_header Access-Control-Allow-Origin *; - - autoindex on; # Enable directory indexing + location / { + proxy_pass http://127.0.0.1:5000; # flask-app is the name of the Flask container in docker-compose + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; } } } diff --git a/web_server/Dockerfile b/web_server/Dockerfile index a63ac40..9e014d8 100644 --- a/web_server/Dockerfile +++ b/web_server/Dockerfile @@ -14,8 +14,5 @@ COPY . . ENV FLASK_APP=blueprints.__init__ ENV FLASK_DEBUG=True -# Expose Flask's port -EXPOSE 5000 - # Start the Flask app -CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0"] +CMD ["gunicorn", "-b", "0.0.0.0:5000", "blueprints.__init__:create_app()"] diff --git a/web_server/database/__pycache__/database.cpython-311.pyc b/web_server/database/__pycache__/database.cpython-311.pyc deleted file mode 100644 index b96531b83bacdea0ac85a6c9f12ddd79ee9ca615..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2082 zcmbVMO>7%Q6rR~1d!0Jjq^Ya?5Opaa)gU5=0EH4&LJ5!*6c8aru`I3DyA#;pc-`4G zP9g`aDhDG4sZk2s4t^bRt(4P@}!5V;4R z-?E&6=TKVsn@wl+L#sCgJ_naz+CT(lv4OxpZtxpImNzgFmc$@nkuwCa#td--W#ixz zgPCM-u(#w&Q<|gYHJi9GN}Mt+&gwV_gfR{u58uI`AR5R48MLL)Z!1VASn|dv__Ezj zv?urmz(xEW4`|=C4LR(Ec|>Ohj>1_*YAo2uK=9|e*|nHfDvcWXbll}E+Z9Th^QkK= zS!U6VYkAw7#toAewPoT;s=8ub^vE1a` z_;}_O1AqLG|f|)`3cNOhd{MidWxdZUS{vpDbXC_#lWUe*0rG!@)K(k zi+>daU@xED{PH{J_DWN}(2_6Ih5h04x8JA>Eoq>g8U(1j+I^|U@Xg_GMsAJNV{JKA z@200AGy*(>#{<3&N&_VjfDD@7wvLq{uptzM2*Z0chn_)B2sA>^B02;mVUNIJtKw+E zFj|1Pb^HaqKXZp#1y|4tzkn*3o`JBmKnGy}9IfSL({U4Tt>~o00CL3=HH%J~^O42G zX0!+ZJ>~nWjMr;tj-d2*@vN*K_QxP5nLO7@p1T|T9_-5l z9fT99Be9?CyYci_)0@-vNPhsW!-FS`HbeRP;0XG@>rKq>$P@f;A}A5uS;ijjuYuC| zpQ!sdaXwC>Ua;Uw_rQMssxsb*bvIWt6?QE~%>5%38r+p?%;>+3s#^(z_LuokGtu z@f?U<l3)V$tCiJI3t!f6aA Po)rHu+rN)l@Q(Tqa$37B diff --git a/web_server/database/requirements.txt b/web_server/database/requirements.txt deleted file mode 100644 index 8ab6294..0000000 --- a/web_server/database/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -flask \ No newline at end of file diff --git a/web_server/requirements.txt b/web_server/requirements.txt index 853ebd4..747b8eb 100644 --- a/web_server/requirements.txt +++ b/web_server/requirements.txt @@ -18,3 +18,4 @@ typing_extensions==4.12.2 urllib3==2.3.0 Werkzeug==3.1.3 WTForms==3.2.1 +Gunicorn==20.1.0 From 178e9597d2316156936f074c41ed50c7857f3e32 Mon Sep 17 00:00:00 2001 From: ThisBirchWood Date: Wed, 22 Jan 2025 01:16:39 +0000 Subject: [PATCH 2/2] Fixed incorrect name --- docker-compose.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index b55b87e..ddacb16 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,13 +7,13 @@ services: - "1935:1935" # RTMP - "8080:8080" depends_on: - - app + - web_server networks: - app_network - app: + web_server: build: - context: ./app + context: ./web_server ports: - "5000:5000" networks: