Skip to content

Instantly share code, notes, and snippets.

@urlsangel
Last active October 30, 2017 21:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save urlsangel/68c74ad49a00d78c64c267b5cd20711e to your computer and use it in GitHub Desktop.
Save urlsangel/68c74ad49a00d78c64c267b5cd20711e to your computer and use it in GitHub Desktop.
Run python with docker-compose
FROM python:3.6.2
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY requirements.txt /usr/src/app/
RUN pip install --no-cache-dir -r requirements.txt
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
ENV LANG en_US.UTF-8
ENV PYTHONIOENCODING utf_8
web:
# assumes your docker-compose.yml is in the root of your project
build: .
# add a docker file for your python image and requirements
dockerfile: .dockerfile
# optional startup command, the line below starts a local Django server
command: python manage.py runserver 0.0.0.0:80
volumes:
# link your source files
- ./:/usr/src/app
ports:
# expose web port
- "80:80"
environment:
# add any environment vars you need
# - DEBUG=True
## add your pip requirements here to be built into the container
@urlsangel
Copy link
Author

  1. Add the gist files to the root of your project
  2. Run docker-compose build
  3. Run docker-compose up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment