Skip to content

Instantly share code, notes, and snippets.

@thebopshoobop
Last active December 11, 2017 02:25
Show Gist options
  • Save thebopshoobop/76973c3ac6d7f5864c51e1ab00671e3a to your computer and use it in GitHub Desktop.
Save thebopshoobop/76973c3ac6d7f5864c51e1ab00671e3a to your computer and use it in GitHub Desktop.
FROM python:3.6
# create working directory
RUN mkdir -p /usr/src/app
RUN mkdir -p /usr/src/py
# install virtualenv globally
RUN pip install virtualenv
# create app user
RUN groupadd -r -g 2000 app
RUN useradd -r -u 2000 -g 2000 -s /usr/bin/nologin app
RUN chown -R 2000:2000 /usr/src
USER app
# switch to working directory
WORKDIR /usr/src/app
# add requirements (to leverage Docker cache)
ADD ./requirements.txt /usr/src/app/requirements.txt
# install requirements
RUN virtualenv /usr/src/py
RUN /usr/src/py/bin/pip install --no-cache-dir -r requirements.txt
# add app
ADD . /usr/src/app
# run server
CMD /usr/src/py/bin/python manage.py run -h 0.0.0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment