I have been using docker containers for running my apps rather than 
virtualenv.  It creates a sandboxed consistent environment from dev to 
production. And with the new docker exec command, easy to get into to make 
changes.

I put the following example Dockerfile in my app root on the host to build 
and deploy the container. 


FROM phusion/baseimage:0.9.15
>
> RUN \
>  apt-get update && apt-get upgrade -y && \
>  apt-get install -y   \
>      build-essential wget curl python python2.7 python-dev python-pip 
> locate nano \
>
> # clean up
> && apt-get clean &&
> rm -rf /var/lib/apt/lists/* 
>
> # create dir for app
> RUN mkdir /opt/app
>
> ENV HOME /root
>
 

> #for pyodbc using config on host/myapp/odbc
> #COPY /odbc/odbcinst.ini /etc/
>
> # get setup.py for the app
> COPY /setup.py /opt/app/
>
> #for apt-get installs for application dependencies, As the dependencies 
> can change, I put these and setup at the end so the previous steps' cache 
> remain the same for quick deployment.
> # COPY install_requirements.sh /
> # RUN sh install_requriements.sh 
>
> # run setup.py
> RUN cd /opt/app \
>     && easy_install tw2.tinymce pyodbc \  #external repositories
>     && pip install -e /opt/app
> # or hg clone https://url into /opt/app and run pip install
>
> WORKDIR /opt/app
>



sudo docker build -t  stuartz/myapps .


set variables on host
MYAPP=the app folder name
DNS1=theIP  # from host using nm-tool
DNS2=theIP  # from host using nm-tool
DOMAIN=domain.com   # from host using nm-tool if any search
PORT=8081  # set port for app same as in development.ini and production.ini


 setup command: \
    sudo docker run -d --name $MYAPP \
    -p 127.0.0.1:$PORT:$PORT \
    -v /opt/$MYAPP:/opt/app \
    -v $MONGOPATH:/data/db \
    --dns=$DNS1 --dns=$DNS2 --dns-search=$DOMAIN \
    stuartz/myapps \
    optionally gearbox cmds here or enter container as below 

enter container to make changes
 sudo docker exec -it $MYAPP bash

if running for the first time to set up db for the app
 cd /opt/$MYAPP
 gearbox setup-app 

if running setup a second time \
    sudo docker stop $MYAPP \
    sudo docker rm $MYAPP \
# otherwise sudo docker stop/start $MYAPP

DEVELOPMENT setup    \
    cd /opt/$MYAPP \
    gearbox serve --debug --reload

PRODUCTION setup \
    cd /opt/$MYAPP \
    gearbox serve -c production.ini
    
 sudo docker commit $MYAPP to save any container state changes


 I use this Dockerfile  in conjunction with nginx as an 
 https proxy_pass to http://localhost:port since I find it easier to 
 provide https coverage through nginx than with apache + mod_wsgi or solo 
TG server
 and static files are directed to /opt/$MYAPP/$myapp/public

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.

Reply via email to