Skip to content

Instantly share code, notes, and snippets.

@rknLA
Created July 29, 2015 21:09
Show Gist options
  • Save rknLA/5c7975f9404cc0753532 to your computer and use it in GitHub Desktop.
Save rknLA/5c7975f9404cc0753532 to your computer and use it in GitHub Desktop.
docker files
FROM private/docker/host/postgres-flask-uwsgi-nginx
MAINTAINER Kevin Nelson "[email protected]"
# Set up nginx by removing the default site, and adding ours
#RUN rm /etc/nginx/sites-enabled/default
RUN ln -s $APP_DIR/deploy/nginx.conf /etc/nginx/conf.d/
# create log folders
RUN mkdir -p /var/log/uwsgi
EXPOSE 8000
# only one CMD per docker file, and exec notation doesn't expand $APP_DIR...
#CMD uwsgi --ini $APP_DIR/uwsgi.ini
CMD ["uwsgi", "--module", "app",\
"--callable", "uwsgi_app",\
"--master",\
"--processes", "5",\
"--threads", "10",\
"--http", "127.0.0.1:8000",\
"--vacuum",\
"--die-on-term"]
FROM debian:jessie
MAINTAINER Kevin Nelson "[email protected]"
# Set up nginx
RUN apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62
RUN echo "deb http://nginx.org/packages/mainline/debian/ jessie nginx" >> /etc/apt/sources.list
ENV NGINX_VERSION 1.9.3-1~jessie
RUN apt-get update && \
apt-get install -y ca-certificates nginx=${NGINX_VERSION} && \
rm -rf /var/lib/apt/lists/*
RUN rm /etc/nginx/conf.d/default.conf
VOLUME ["/var/cache/nginx"]
# Set up python / flask / uwsgi
RUN apt-get update && apt-get install -y -q \
build-essential \
git \
postgresql-client-9.4 \
postgresql-client-common \
python-dev \
python-pip \
python-psycopg2 \
&& rm -rf /var/lib/apt/lists/*
# Install required pip dependencies, including uwsgi
COPY requirements.txt /tmp/
RUN pip install -r /tmp/requirements.txt
# Create a place to deploy the app
ENV APP_DIR /var/www/app
RUN mkdir -p $APP_DIR
WORKDIR $APP_DIR
# When building a downstream image, copy the application files and then setup
# additional dependencies. It's assumed the application files are present in
# the same directory as the downstream build's Dockerfile.
ONBUILD COPY . $APP_DIR/
ONBUILD RUN pip install -r $APP_DIR/requirements.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment