diff --git a/Dockerfile b/Dockerfile index a093686..ed6f1a6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,16 @@ -FROM python:3.9.1 -ADD . /app -WORKDIR /app -RUN pip install -r requirements.txt \ No newline at end of file +FROM python:3.9.1-slim +COPY . /srv/flask_app +WORKDIR /srv/flask_app + +RUN apt-get clean \ + && apt-get -y update + +RUN apt-get -y install nginx \ + && apt-get -y install python3-dev \ + && apt-get -y install build-essential + +RUN pip install -r requirements.txt --src /usr/local/src + +COPY nginx.conf /etc/nginx +RUN chmod +x ./start.sh +CMD ["./start.sh"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index d422877..e90b659 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,9 +2,10 @@ version: "3.8" services: app: build: . - command: python app.py ports: - - "5000:5000" + - "5000:80" volumes: - .:/app - container_name: trhlina-bar \ No newline at end of file + container_name: trhlina-bar + env_file: + - config.env \ No newline at end of file diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..25ad077 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,37 @@ +user www-data; +worker_processes auto; +pid /run/nginx.pid; + +events { + worker_connections 1024; + use epoll; + multi_accept on; +} + +http { + access_log /dev/stdout; + error_log /dev/stdout; + + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + types_hash_max_size 2048; + + include /etc/nginx/mime.types; + default_type application/octet-stream; + + index index.html index.htm; + + server { + listen 80 default_server; + listen [::]:80 default_server; + server_name localhost; + root /var/www/html; + + location / { + include uwsgi_params; + uwsgi_pass unix:/tmp/uwsgi.socket; + } + } +} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 16dc198..9580d79 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ flask -pygrocy \ No newline at end of file +pygrocy +uWSGI \ No newline at end of file diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..a5ff419 --- /dev/null +++ b/start.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +service nginx start +uwsgi --ini uwsgi.ini \ No newline at end of file diff --git a/uwsgi.ini b/uwsgi.ini new file mode 100644 index 0000000..e81ddd1 --- /dev/null +++ b/uwsgi.ini @@ -0,0 +1,12 @@ +[uwsgi] +module = app:app +uid = www-data +gid = www-data +master = true +processes = 2 + +socket = /tmp/uwsgi.socket +chmod-sock = 664 +vacuum = true + +die-on-term = true