Dockerize using uwsgi, not plain flask
This commit is contained in:
parent
0a667a153a
commit
e7cd66c82d
6 changed files with 74 additions and 8 deletions
20
Dockerfile
20
Dockerfile
|
@ -1,4 +1,16 @@
|
|||
FROM python:3.9.1
|
||||
ADD . /app
|
||||
WORKDIR /app
|
||||
RUN pip install -r requirements.txt
|
||||
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"]
|
|
@ -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
|
||||
container_name: trhlina-bar
|
||||
env_file:
|
||||
- config.env
|
37
nginx.conf
Normal file
37
nginx.conf
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,2 +1,3 @@
|
|||
flask
|
||||
pygrocy
|
||||
pygrocy
|
||||
uWSGI
|
3
start.sh
Normal file
3
start.sh
Normal file
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env bash
|
||||
service nginx start
|
||||
uwsgi --ini uwsgi.ini
|
12
uwsgi.ini
Normal file
12
uwsgi.ini
Normal file
|
@ -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
|
Loading…
Reference in a new issue