Skip to content

Instantly share code, notes, and snippets.

@rachelmyers
Created September 23, 2016 23:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rachelmyers/1ad342f7a82be3234597e7c698411235 to your computer and use it in GitHub Desktop.
Save rachelmyers/1ad342f7a82be3234597e7c698411235 to your computer and use it in GitHub Desktop.
Annotated Dockerfile for a Flask / Python application
# Set a base Docker image to inherit from
FROM ubuntu:14.04
# This isn't required, but give yourself some credit
MAINTAINER Your Name Here <Your Email Here>
# If you get a library from Homebrew (or `apt-get`) to run it locally, add it to
# this list and Docker will install it with `apt-get`.
RUN DEBIAN_FRONTEND=noninteractive apt-get update --fix-missing && apt-get install -y \
bcrypt \
build-essential \
git \
libffi-dev \
libjpeg-dev \
libpng-dev \
libpq-dev \
libssl-dev \
python \
python-dev \
python-setuptools \
rsyslog \
supervisor \
vim \
wget
# Create directories in the container for logs and source code
RUN mkdir /var/log/gunicorn && mkdir /var/log/deploys
RUN mkdir /opt/code
# Add and install everything listed in `requirements.txt`
RUN easy_install pip
COPY ./app/files/requirements.txt /opt/code/
RUN pip install -r /opt/code/requirements.txt
# Expose port 80 as the default for flask apps
EXPOSE 80
# Set `opt/code` as the default directory for future instructions (i.e. `CMD`)
WORKDIR /opt/code
# Start the application with `supervisord`
CMD supervisord -c /etc/supervisor/conf.d/supervisord.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment