[web2py] Re: web2py gunicorn dockerfile

2018-02-04 Thread 黄祥
done

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.


[web2py] Re: web2py gunicorn dockerfile

2018-02-03 Thread Massimo Di Pierro
Can I ask you to submit a PR to add the dockerfile to the web2py repo?

On Saturday, 27 January 2018 07:12:26 UTC-6, 黄祥 wrote:
>
> want to share the docker stack recipe, if anyone interest perhaps i can pr 
> to the web2py repo or share it on this group
> [stack] 
> $ ls | grep web2py
> web2py-gunicorn-nginx
> web2py-rocket-nginx
> web2py-rocket-ssl-nginx
> web2py-rocket-ssl-nginx-db-adminer
> web2py-rocket-ssl-nginx-memcached
> web2py-rocket-ssl-nginx-redis
> web2py-tornado-nginx
>
> [alpine] 
> $ ls | grep web2py
> web2py-gunicorn
> web2py-rocket
> web2py-rocket-ssl
> web2py-tornado
>
> *note:*
> - for os base and python base image, better to choose alpine for the size 
> is smallest than any other os base image (tested using centos, debian, 
> fedora, opensuse, ubuntu) and python base image
> - in stack there is provided the docker-compose.yml and the run.sh (run 
> docker using shell script run.sh (guided by alec on previous post) )
> - everything is tested run well in play-with-docker.com
>
> *need improvement for the script (still learning)*
> - for web2py rocket, hardcode the password to run the rocket server, 
> better to put it as a variable base on user input, but i don't know to do 
> it when using docker compose
> - tested web2py-cherrypy ended with error in the anyserver.py is not 
> update the cherrypy library file
> - in web2py-rocket-ssl the certificate is build using openssl, which is 
> ended to confirm when using in https (go to unsafe), think better using 
> letsencrypt or something else
> - for stack using ldap server, still not found the good image for it, 
> tried to built it from the os base image, ended in configuration of ldap 
> server must be entered by user during setup (setup-ds-admin when using 
> 389-ds and dpkg-reconfigure slapd when using openldap)
> - tried to combine stack memcached and redis, not sure if it can be used 
> both (the configuration of the parameter cache and session in web2py)
> - tried to build haproxy stack, but not sure the configuration in web2py 
> book is relevant with the haproxy current version
>
> 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.


[web2py] Re: web2py gunicorn dockerfile

2018-01-27 Thread 黄祥
want to share the docker stack recipe, if anyone interest perhaps i can pr 
to the web2py repo or share it on this group
[stack] 
$ ls | grep web2py
web2py-gunicorn-nginx
web2py-rocket-nginx
web2py-rocket-ssl-nginx
web2py-rocket-ssl-nginx-db-adminer
web2py-rocket-ssl-nginx-memcached
web2py-rocket-ssl-nginx-redis
web2py-tornado-nginx

[alpine] 
$ ls | grep web2py
web2py-gunicorn
web2py-rocket
web2py-rocket-ssl
web2py-tornado

*note:*
- for os base and python base image, better to choose alpine for the size 
is smallest than any other os base image (tested using centos, debian, 
fedora, opensuse, ubuntu) and python base image
- in stack there is provided the docker-compose.yml and the run.sh (run 
docker using shell script run.sh (guided by alec on previous post) )
- everything is tested run well in play-with-docker.com

*need improvement for the script (still learning)*
- for web2py rocket, hardcode the password to run the rocket server, better 
to put it as a variable base on user input, but i don't know to do it when 
using docker compose
- tested web2py-cherrypy ended with error in the anyserver.py is not update 
the cherrypy library file
- in web2py-rocket-ssl the certificate is build using openssl, which is 
ended to confirm when using in https (go to unsafe), think better using 
letsencrypt or something else
- for stack using ldap server, still not found the good image for it, tried 
to built it from the os base image, ended in configuration of ldap server 
must be entered by user during setup (setup-ds-admin when using 389-ds and 
dpkg-reconfigure slapd when using openldap)
- tried to combine stack memcached and redis, not sure if it can be used 
both (the configuration of the parameter cache and session in web2py)
- tried to build haproxy stack, but not sure the configuration in web2py 
book is relevant with the haproxy current version

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.


[web2py] Re: web2py gunicorn dockerfile

2018-01-09 Thread 黄祥
it works well, my bad, forgot about shell variable is translated when 
created file using cat

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.


[web2py] Re: web2py gunicorn dockerfile

2018-01-09 Thread 黄祥
thanks again alex, when executed same like previous tested in 
https://labs.play-with-docker.com, return an error (acceptable i think 
because the link and port provided is work (shown web2py welcome apps) )
*error traceback*
PING 172.25.0.23 (172.25.0.23): 56 data bytes

--- 172.25.0.23 ping statistics ---
1 packets transmitted, 0 packets received, 100% packet loss
curl: (7) Failed to connect to 172.25.0.23 port 80: Host is unreachable
is it normal or not?

*1. w2p.conf*
cat < w2p.conf
upstream gunicorn {
#server  172.25.0.22:9005 fail_timeout=0;
server  w2pname:9005 fail_timeout=0;
}

server {
#listen172.25.0.23:80 default_server;
listennginxname: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;
}
}

EOF
cat w2p.conf

*4. run dockers in shell script*
cat < 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
ping -c1 -n 172.25.0.22
curl 172.25.0.22
curl -I 172.25.0.22:9005

docker build -t w2pnginx -f nginxDoc .
docker run -d --net w2pnet --ip 172.25.0.23  w2pnginx
sleep 2
ping -c1 -n 172.25.0.23
curl 172.25.0.23
curl -I 172.25.0.23

docker ps
docker network ls
docker network inspect w2pnet

EOF
cat run.sh

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.


[web2py] Re: web2py gunicorn dockerfile

2018-01-09 Thread Alex Beskopilny
small fix - use dockerDNS
1
# 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 --subnet=172.25.0.0/16 w2pnet

docker build -t w2pguni -f guniDoc .
docker run -d --net w2pnet -p 9005:9005 --name w2pname  --ip 172.25.0.22   
w2pguni
# docker exec -it w2pname  bash

sleep 2
ping -c1 -n 172.25.0.22
docker run --net w2pnet busybox ping -c1 -n w2pname
echo "--"
curl -I 172.25.0.22:9005

docker build -t w2pnginx -f nginxDoc .
docker run -d --net w2pnet --name nginxname --ip 172.25.0.23  w2pnginx
# docker exec -it nginxname  bash

sleep 2
ping -c1 -n 172.25.0.23
docker run --net w2pnet busybox ping -c1 -n nginxname
echo "--"
curl -I 172.25.0.23

docker ps
docker network ls
docker network inspect w2pnet

2
#w2p.conf
upstream gunicorn {
server  w2pname:9005 fail_timeout=0;
}

server {
listennginxname:80 default_server;
#listen172.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;
}

}



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 < 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 
> 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 < 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.


[web2py] Re: web2py gunicorn dockerfile

2018-01-09 Thread 黄祥
thanks alex, tested in https://labs.play-with-docker.com, it works fine
never thought to combine it with gunicorn and make nginx as a reverse proxy 
(correct me if i'm wrong, still not sure the different with forward proxy 
yet, hehe) and never thought to build some dockerfiles make it into 1 bash 
shell script.
*1. w2p.conf*
cat < w2p.conf
upstream gunicorn {
server  172.25.0.22:9005 fail_timeout=0;
}
server {
listen172.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;
}
}
EOF
cat w2p.conf

*2. gunicorn*
cat < 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
EOF
cat guniDoc

*3. nginx as reverse proxy*
cat < 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;"
EOF
cat nginxDoc

*4. run dockers in shell script*
cat < 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
EOF
cat run.sh

*5. execute run.sh*
chmod 775 run.sh
./run.sh

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.


[web2py] Re: web2py gunicorn dockerfile

2018-01-09 Thread Alex Beskopilny
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 {
listen172.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 < 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 
> 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 < 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.


[web2py] Re: web2py gunicorn dockerfile

2018-01-08 Thread 黄祥
trying with latest ubuntu and web2py/scripts/setup-web2py-ubuntu.sh return 
an error
Failed to connect to bus: No such file or directory
step i took
echo '# Emperor uWSGI script

description "uWSGI Emperor"
start on runlevel [2345]
stop on runlevel [06]
##
#remove the comments in the next section to enable static file compression 
for the welcome app
#in that case, turn on gzip_static on; on /etc/nginx/nginx.conf
##
#pre-start script
#python /home/www-data/web2py/web2py.py -S welcome -R 
scripts/zip_static_files.py
#chown -R www-data:www-data /home/www-data/web2py/*
#end script
respawn
exec uwsgi --master --die-on-term --emperor /etc/uwsgi --logto 
/var/log/uwsgi/uwsgi.log
' > uwsgi-emperor.conf
cat uwsgi-emperor.conf

echo '[uwsgi]

socket = /tmp/web2py.socket
pythonpath = /home/www-data/web2py/
mount = /=wsgihandler:application
processes = 4
master = true
harakiri = 60
reload-mercy = 8
cpu-affinity = 1
stats = /tmp/stats.socket
max-requests = 2000
limit-as = 512
reload-on-as = 256
reload-on-rss = 192
uid = www-data
gid = www-data
touch-reload = /home/www-data/web2py/routes.py
cron = 0 0 -1 -1 -1 python /home/www-data/web2py/web2py.py -Q -S welcome -M 
-R scripts/sessions2trash.py -A -o
no-orphans = true
' > web2py.ini
cat web2py.ini

echo '[Unit]
Description = uWSGI Emperor
After = syslog.target

[Service]
ExecStart = /usr/local/bin/uwsgi --ini /etc/uwsgi/web2py.ini
RuntimeDirectory = uwsgi
Restart = always
KillSignal = SIGQUIT
Type = notify
StandardError = syslog
NotifyAccess = all

[Install]
WantedBy = multi-user.target
' > uwsgi.emperor.service
cat uwsgi.emperor.service

echo 'server {
listen  80;
server_name ubuntu;
###to enable correct use of response.static_version
location ~* ^/(\w+)/static(?:/_[\d]+\.[\d]+\.[\d]+)?/(.*)$ {
alias /home/www-data/web2py/applications/$1/static/$2;
expires max;
### if you want to use pre-gzipped static files (recommended)
### check scripts/zip_static_files.py and remove the comments
# include /etc/nginx/conf.d/web2py/gzip_static.conf;
}
###

###if you use something like myapp = dict(languages=['en', 'it', 
'jp'], default_language='en') in your routes.py
#location ~* ^/(\w+)/(en|it|jp)/static/(.*)$ {
#alias /home/www-data/web2py/applications/$1/;
#try_files static/$2/$3 static/$3 =404;
#}
###

location / {
#uwsgi_pass  127.0.0.1:9001;
uwsgi_pass  unix:///tmp/web2py.socket;
include uwsgi_params;
uwsgi_param UWSGI_SCHEME $scheme;
uwsgi_param SERVER_SOFTWAREnginx/$nginx_version;

###remove the comments to turn on if you want gzip compression 
of your pages
# include /etc/nginx/conf.d/web2py/gzip.conf;
### end gzip section

### remove the comments if you use uploads (max 10 MB)
#client_max_body_size 10m;
###
}
}
server {
listen 443 default_server ssl;
server_name ubuntu;
ssl_certificate /etc/nginx/ssl/web2py.crt;
ssl_certificate_key /etc/nginx/ssl/web2py.key;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
ssl_ciphers 
ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
keepalive_timeout70;
location / {
#uwsgi_pass  127.0.0.1:9001;
uwsgi_pass  unix:///tmp/web2py.socket;
include uwsgi_params;
uwsgi_param UWSGI_SCHEME $scheme;
uwsgi_param SERVER_SOFTWAREnginx/$nginx_version;
###remove the comments to turn on if you want gzip compression 
of your pages
# include /etc/nginx/conf.d/web2py/gzip.conf;
### end gzip section
### remove the comments if you want to enable uploads (max 10 
MB)
#client_max_body_size 10m;
###
}
###to enable correct use of response.static_version
location ~* ^/(\w+)/static(?:/_[\d]+\.[\d]+\.[\d]+)?/(.*)$ {
alias /home/www-data/web2py/applications/$1/static/$2;
expires max;
### if you want to use pre-gzipped static files (recommended)
### check scripts/zip_static_files.py and remove the comments
# include /etc/nginx/conf.d/web2py/gzip_static.conf;
}
###

}' > web2py
cat web2py

cat < Dockerfile
FROM ubuntu:latest
RUN apt update && \
 apt -y install sudo curl unzip python-dev python-pip python-setuptools gcc 
nginx && \
 pip install --upgrade pip uwsgi && \
 mkdir /etc/uwsgi && \
 mkdir /var/log/uwsgi && \
 mkdir /home/www-data && \
 mkdir -p /etc/nginx/ssl/ && \
 ln -s /etc/nginx/sites-available/web2py /etc/nginx

[web2py] Re: web2py gunicorn dockerfile

2018-01-07 Thread 黄祥
is there any dockerfile that contain web2py with nginx ?

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.


[web2py] Re: web2py gunicorn dockerfile

2018-01-06 Thread Alex Beskopilny
small fix
1
FROM python:2.7
RUN apt update && apt install -y unzip wget
RUN /usr/local/bin/pip install gunicorn
RUN groupadd -r web2py &&  useradd -m -r -g web2py web2py
USER web2py
WORKDIR /home/web2py
RUN  wget -c http://web2py.com/examples/static/web2py_src.zip &&  unzip -o 
web2py_src.zip &&  rm -rf /home/web2py/web2py/applications/examples
EXPOSE 8000
WORKDIR /home/web2py/web2py
CMD /usr/local/bin/python anyserver.py -s gunicorn -i 0.0.0.0 -p 8000
2
 docker build -t w2p33 .
docker run -p3001:8000 -t w2p33
3
curl -I http://localhost:3001
HTTP/1.1 303 SEE OTHER
Server: gunicorn/19.7.1
Date: Sun, 07 Jan 2018 04:37:27 GMT
Connection: close
Content-Type: text/html; charset=UTF-8
Location: /welcome/default/index


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 < 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 
> 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 < 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.


[web2py] Re: web2py gunicorn dockerfile

2018-01-06 Thread Alex Beskopilny

1 Dockerfile
FROM python:2.7
RUN apt update &&  apt install -y unzip wget
RUN /usr/local/bin/pip install 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 8000
WORKDIR /home/web2py/web2py
CMD cd ~ && /usr/local/bin/python /home/web2py/web2py/anyserver.py -s 
gunicorn -i 0.0.0.0 -p 8000
2 
docker build -t w2p33 .
docker run -t w2p33
3 
curl -I http://localhost:3001
HTTP/1.1 303 SEE OTHER
Server: gunicorn/19.7.1
Date: Sun, 07 Jan 2018 04:13:58 GMT
Connection: close
Content-Type: text/html; charset=UTF-8
Location: /welcome/default/index

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 < 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 
> 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 < 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.


[web2py] Re: web2py gunicorn dockerfile

2018-01-06 Thread 黄祥
after reread and relearn your dockerfile again it works with some 
modification with python image (installed gunicorn from pip install not 
from apt install, and port set into 8000, port 80 not work)
docker run -p 80:80 imageid
[2018-01-07 01:02:10 +] [8] [INFO] Starting gunicorn 19.7.1
[2018-01-07 01:02:10 +] [8] [ERROR] Retrying in 1 second.
[2018-01-07 01:02:11 +] [8] [ERROR] Retrying in 1 second.
[2018-01-07 01:02:12 +] [8] [ERROR] Retrying in 1 second.
[2018-01-07 01:02:13 +] [8] [ERROR] Retrying in 1 second.
[2018-01-07 01:02:14 +] [8] [ERROR] Retrying in 1 second.
starting gunicorn on 0.0.0.0:80...
[2018-01-07 01:02:15 +] [8] [ERROR] Can't connect to ('0.0.0.0', 80)

here is the dockerfile that is work with python image
cat < Dockerfile
FROM python:2.7
RUN apt update && \
 apt install -y unzip wget python-pip
RUN pip install gunicorn && \
 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
WORKDIR /home/web2py/web2py
EXPOSE 8000
CMD cd ~ && python /home/web2py/web2py/anyserver.py -s gunicorn -i 0.0.0.0 
-p 8000
EOF
cat Dockerfile
docker build .
docker images
docker run -p 8000:8000 imageid

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.


[web2py] Re: web2py gunicorn dockerfile

2018-01-06 Thread 黄祥
yes, it works when using os base image (tested using ubuntu (like in the 
first post), centos, debian, fedora), the problem occured when using python 
base image.
the point is when using os base image, it took longer (to install 
prerequisites package like python curl, git, dll) than using python base 
image. (tested using web2py source default scaffolding app and rocket)

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.


[web2py] Re: web2py gunicorn dockerfile

2018-01-05 Thread 黄祥
trying to modify but got another error 
*e.g.*
*step i took on play-with-docker.com*
cat < 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
*WORKDIR /home/web2py/web2py # modified*
EXPOSE 80
*CMD . /home/web2py/web2py/anyserver.py -s gunicorn -i 0.0.0.0 -p 80** # 
modified*
EOF
docker build .
docker images
docker run -p 3001:80 imageid* # same result*
docker run -p 80:80 imageid* # same result*

*result*
/bin/sh: 10: /home/web2py/web2py/anyserver.py:
This file is part of the web2py Web Framework
Copyrighted by Massimo Di Pierro 
License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)

This file is based, although a rewrite, on MIT-licensed code from the 
Bottle web framework.
: not found
import: unable to open X server `' @ error/import.c/ImportImageCommand/364.
import: unable to open X server `' @ error/import.c/ImportImageCommand/364.
import: unable to open X server `' @ error/import.c/ImportImageCommand/364.
import: unable to open X server `' @ error/import.c/ImportImageCommand/364.

fyi, the python:2.7 dockerfile is work when using default rocket web server 
(different from above just install the gunicorn package and the cmd to 
execute the server)
tested to map the port 3001 and 80 from example above got the same result

any idea ?

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.


[web2py] Re: web2py gunicorn dockerfile

2018-01-05 Thread Alex Beskopilny
Hi
set  WORKDIR in Dockerfile
..
WORKDIR /home/site/web2py
EXPOSE 80
CMD . /home/..
..
docker run 3001:80 image-name

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 < 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 
> 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 < 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.