Public Repository

Last pushed: 3 years ago
Short Description
Web2py image with nginx server base on a ubuntu 14.04.02.
Full Description

This is a web2py installation with nginx server.

  • ubuntu 14.04.02
  • uwsgi
  • automatic ssl certificate

Sources files:

Original source for the installation :

# Dockerfile
FROM ubuntu:14.04.2


# use nginx_version="development" for latest development version
ENV nginx_version="stable"
ENV web2py_pass="password"

RUN apt-get update && \
    apt-get install -y software-properties-common && \
    add-apt-repository ppa:nginx/${nginx_version} && \
    apt-get update && \
    apt-get install -y build-essential nano wget supervisor && \
    apt-get install -y python python-dev libxml2-dev python-setuptools python-pip unzip nginx-full

#uwsgi install
RUN pip install setuptools --no-use-wheel --upgrade && \
    PIPPATH=`which pip` && \
    $PIPPATH install --upgrade uwsgi

# Configure gzip
RUN mkdir /etc/nginx/conf.d/web2py
COPY gzip_static.conf /etc/nginx/conf.d/web2py/gzip_static.conf
COPY gzip.conf /etc/nginx/conf.d/web2py/gzip.conf

# Configure nginx
COPY web2py /etc/nginx/sites-available/web2py
RUN ln -s /etc/nginx/sites-available/web2py /etc/nginx/sites-enabled/web2py
RUN rm /etc/nginx/sites-enabled/default
RUN echo "\ndaemon off;" >> /etc/nginx/nginx.conf

#Create ssl certificate
RUN mkdir /etc/nginx/ssl
RUN cd /etc/nginx/ssl && \
    openssl genrsa -out web2py.key 1024 && \
    chmod 400 web2py.key && \
    openssl req -batch -new -key web2py.key -out web2py.csr && \
    openssl x509 -req -days 1780 -in web2py.csr -signkey web2py.key -out web2py.crt

#Configure uwsgi
RUN sudo mkdir /etc/uwsgi
RUN sudo mkdir /var/log/uwsgi
COPY web2py.ini /etc/uwsgi/web2py.ini

# Install Web2py
RUN mkdir /home/www-data
RUN cd /home/www-data && \
    pwd && \
    wget && \
    unzip && \
    mv web2py/handlers/ web2py/ && \
    rm && \
    chown -R www-data:www-data web2py
RUN cd /home/www-data/web2py && \
    python -c "from gluon.main import save_password; save_password('${web2py_pass}',443)"

#Configure supervisor
COPY supervisor-app.conf /etc/supervisor/conf.d/

EXPOSE 80 443

CMD ["supervisord", "-n"]

# End Dockerfile

##Link data container with web2py
docker create -v <source folder path>:/data --name my_web2py_data my_web2py/nginx

##build the image:
docker build -t my_web2py/nginx .

##start container:
docker run -d -p 9090:80 -p 9443:443 --volumes-from my_web2py_data --name my_web2py_nginx my_web2py/nginx

##connect to the image started:
docker exec -it my_web2py_nginx bash

##to start nano:
export TERM=xterm

##load the web page:

Docker Pull Command