four files in same directory 1 #guniDoc FROM python:2.7 RUN apt update && apt install -y unzip wget ENV PATH=/usr/local/bin:$PATH RUN pip install gunicorn
RUN useradd -m -r web2py USER web2py WORKDIR /home/web2py RUN wget -c http://web2py.com/examples/static/web2py_src.zip && \ unzip -o web2py_src.zip && \ rm -f web2py_src.zip WORKDIR /home/web2py/web2py RUN cp handlers/wsgihandler.py . CMD /usr/local/bin/gunicorn --workers 4 --timeout=90 --graceful-timeout=10 --bind :9005 wsgihandler:application 2 #nginxDoc FROM nginx:latest COPY ./w2p.conf /etc/nginx/conf.d/ RUN apt update RUN apt-get install curl -y EXPOSE 80 CMD nginx -g "daemon off;" 3 #w2p.conf upstream gunicorn { server 172.25.0.22:9005 fail_timeout=0; } server { listen 172.25.0.23:80 default_server; location / { try_files $uri @proxy_to_gunicorn; } location @proxy_to_gunicorn { proxy_set_header X-Real-IP $remote_addr; proxy_redirect off; proxy_set_header Host $host; proxy_pass http://gunicorn; } } 4 #run.sh docker rm $(docker stop $(docker ps -a -q --filter ancestor=w2pnginx --format="{{.ID}}")) docker rm $(docker stop $(docker ps -a -q --filter ancestor=w2pguni --format="{{.ID}}")) docker network rm w2pnet #docker network create w2pnet docker network create --subnet=172.25.0.0/16 w2pnet docker build -t w2pguni -f guniDoc . docker run -d --net w2pnet -p 9005:9005 --hostname w2pname --ip 172.25.0.22 w2pguni sleep 2 curl 172.25.0.22 docker build -t w2pnginx -f nginxDoc . docker run -d --net w2pnet --ip 172.25.0.23 w2pnginx sleep 2 curl 172.25.0.23 docker ps ---------------------------- . run.sh view with firefox http://172.25.0.23 On Friday, January 5, 2018 at 5:45:04 AM UTC+3, 黄祥 wrote: > > just wondering why gunicorn dockerfile with web2py/anyserver.py is not > work when use with python:2.7 image > e.g. > *step i took* > cat <<EOF > Dockerfile > FROM python:2.7 > RUN apt update && \ > apt install -y unzip wget gunicorn > RUN groupadd -r web2py && \ > useradd -m -r -g web2py web2py > USER web2py > RUN cd /home/web2py/ && \ > wget -c http://web2py.com/examples/static/web2py_src.zip && \ > unzip -o web2py_src.zip && \ > rm -rf /home/web2py/web2py/applications/examples && \ > chmod 755 -R /home/web2py/web2py > EXPOSE 80 > CMD cd ~ && python /home/web2py/web2py/anyserver.py -s gunicorn -i 0.0.0.0 > -p 80 > EOF > docker build . > docker images > docker run -p 80:80 imageid > > *result* > starting gunicorn on 0.0.0.0:80... > Traceback (most recent call last): > File "/home/web2py/web2py/anyserver.py", line 365, in <module> > main() > File "/home/web2py/web2py/anyserver.py", line 362, in main > options=options) > File "/home/web2py/web2py/anyserver.py", line 314, in run > getattr(Servers, servername)(application, (ip, int(port)), > options=options) > File "/home/web2py/web2py/anyserver.py", line 137, in gunicorn > from gunicorn.app.base import Application > ImportError: No module named gunicorn.app.base > > but it works well when using ubuntu latest image > *e.g.* > *step i took* > cat <<EOF > Dockerfile > FROM ubuntu:latest > RUN apt update && \ > apt install -y python python-pip python-setuptools unzip vim wget > gunicorn && \ > pip install --upgrade pip && \ > pip install virtualenv && \ > virtualenv /home/site && \ > rm -rf /home/site/web2py && \ > cd /home/site/ && \ > rm -f web2py_src.zip && \ > wget -c http://web2py.com/examples/static/web2py_src.zip && \ > unzip -o web2py_src.zip && \ > rm -rf /home/site/web2py/applications/examples && \ > chmod 755 -R /home/site/web2py > EXPOSE 80 > CMD . /home/site/bin/activate && /usr/bin/python > /home/site/web2py/anyserver.py -s gunicorn -i 0.0.0.0 -p 80 > EOF > docker build . > docker images > docker run -p 80:80 imageid > > all tested in https://labs.play-with-docker.com > > thanks and best regards, > stifan > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.