When you just want to run it on CentOS, which you can throw away.
python3 should be installed with virtualenv.
(Addition)
Finally I wrote a Dockerfile. I just rewrote this procedure into a Dockerfile. The resulting image will be 600MB, so I think it's too heavy.
Will it still be lighter if I remake it with alpine? I would like to know the best practices for running flask in a production environment.
Versions
CentOS
CentOS Linux release 7.6.1810 (Core)
HTTPD
Also install httpd-devel
.
httpd-tools-2.4.6-90.el7.centos.x86_64
httpd-2.4.6-90.el7.centos.x86_64
httpd-devel-2.4.6-90.el7.centos.x86_64
PYTHON
Enter with yum install python3
Python 3.6.8
mod_wsgi
with yum
.pip3 install mod_wsgi
gcc
when installing this.yum install httpd httpd-devel python3 python3-devel gcc -y
pip3 install mod_wsgi
LoadModule
, specify the one installed above. This is the version of Python that Apache runs.python-path
specifies the Path including site-packages
Listen 8080
properly in the parent ball conf[root@ryo httpd]# cat /etc/httpd/conf.d/userdir.conf
<VirtualHost *:8080>
ServerName example.com
LoadModule wsgi_module /usr/local/lib64/python3.6/site-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so
WSGIDaemonProcess ml user=vagrant group=vagrant threads=5 python-path=/usr/local/lib64/python3.6/site-packages
WSGIScriptAlias / /opt/tryml/ryo/wsgi.wsgi
<Directory /opt/tryml/ryo/>
WSGIProcessGroup ml
Order deny,allow
Allow from all
Require all granted
</Directory>
</VirtualHost>
import sys, os
sys.path.insert(0, os.path.dirname(__file__))
from sebserver import app as application
Dockerfile
FROM centos:7
COPY ["*.py", "wsgi.wsgi", "requirements.txt", "/var/www/html/"]
RUN yum install httpd httpd-devel python3 python3-devel gcc -y; pip3 install -r /var/www/html/requirements.txt; mkdir /var/www/html/static; chown apache:apache /var/www/html/*
COPY templates/sample.html /var/www/html/templates/
COPY docker/py.conf /etc/httpd/conf.d/
COPY docker/httpd.conf /etc/httpd/conf/
CMD ["/usr/sbin/httpd", "-DFOREGROUND"]
Recommended Posts