Hello everyone
I’m having a bit of trouble with a local development workflow, when we’re building an app.
I’ve pasted the dockerfile and docker-compose.yml files we’re using below, and everything works as expected.
docker-compose up
everything is running, I can see the site and make code alterations successfully
what I’m struggling with now is adding a python module to the Dockerfile, and get that change to take effect in my container.
the only way I’ve found so far, and I’m having some different sorts of results doing this, add the new module to requirements.txt, then bring everything down
docker-compose down
then find the pcstudents_web image, and all it’s child images, delete them, then run
docker-compose up
sometimes that works ok, sometimes I’m blowing away my data volume, sometimes it doesn’t work at all
I’m pretty certain it’s because of the order I’m doing things, and/or not going them correctly either probably
Am I going down the right track here, or is there a much easier way to accomplish what I’m trying to do, or am i just doing it all wrong?
any hints or tips or links, greatly appreciated
docker-compose.yml
version: '2’
services:
pgdata:
image: cogniteev/echo
command: echo 'Data Container for PostgreSQL’
volumes:
- /var/lib/postgresql/data
pcstudents_db:
image: "postgres:9.4"
volumes_from:
- pgdata
expose:
- 5432
pcstudents_web:
build: .
command: python manage.py runserver 0.0.0.0:8000 --settings=pcstudents.settings.dev
volumes:
- .:/code
ports:
- "8000:8000"
depends_on:
- pcstudents_db
Dockerfile
FROM python:2.7
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
ADD requirements.txt /code/
RUN pip install -r requirements.txt
ADD . /code/