Create a dev docker container for makemigrations

* Adds a laptop-mode-env file which docker can read env variables from
* Adds a Dockerfile.makemigrations; mostly identical to the main
  Dockerfile. Important difference: instead of the source being copied
  into the docker image at build time, it's mounted from the local
  machine at run time.
* Adds a makemigrations shell script which builds an imagine using the
  Dockefile.makemigrations and then uses it to run makemigrations
* Because the source is mounted from the local machine, any new
  migrations created are dumped in the developer's git checkout ready
  for adding to git.

Rename .env -> docker/laptop-mode-env
This commit is contained in:
James Polley 2017-07-31 22:41:47 +10:00
parent 855c71eaca
commit fb5d0b8941
4 changed files with 50 additions and 0 deletions

View file

@ -0,0 +1,22 @@
FROM python:3.6
VOLUME /source
COPY constraints.txt requirements.txt /setup/
RUN set -ex \
&& buildDeps=' \
libmysqlclient-dev \
libffi-dev \
libfreetype6-dev \
libjpeg-dev \
libwebp-dev \
libpng-dev \
liblcms2-dev \
zlib1g-dev \
libmemcached-dev \
libsasl2-dev \
' \
&& apt-get update \
&& apt-get install -y git xmlsec1 libmysqlclient18 \
&& apt-get install -y $buildDeps --no-install-recommends
RUN pip install -c /setup/constraints.txt -r /setup/requirements.txt
CMD ["python","/source/manage.py", "makemigrations"]

6
docker/laptop-mode-env Normal file
View file

@ -0,0 +1,6 @@
DJANGO_SECRET_KEY=5CEA51A5-A613-4AEF-A9FB-D0A57D77C13B
STRIPE_PUBLIC_KEY=5CEA51A5-A613-4AEF-A9FB-D0A57D77C13B
STRIPE_SECRET_KEY=5CEA51A5-A613-4AEF-A9FB-D0A57D77C13B
GCS_BUCKET=5CEA51A5-A613-4AEF-A9FB-D0A57D77C13B
GOOGLE_APPLICATION_CREDENTIALS=/dev/null
DATABASE_URL=sqlite:////tmp/symposion.sqlite

18
make_dev_container.sh Executable file
View file

@ -0,0 +1,18 @@
#!/bin/bash -x
CONTAINER_NAME=${1:-symposion_app}
docker image build -f docker/Dockerfile -t ${CONTAINER_NAME} .
docker container stop symposion
docker container rm symposion
docker container create --env-file docker/laptop-mode-env -p 28000:8000 --name symposion ${CONTAINER_NAME}
docker container start symposion
docker exec symposion ./manage.py migrate
docker exec symposion ./manage.py loaddata ./fixtures/*.json
docker exec symposion ./manage.py create_review_permissions
docker exec -it symposion ./manage.py createsuperuser
## The following sets up everything required for rego - tickets and
## t-shirts and stuff. At this stage, it's not something we want.
#docker exec symposion ./manage.py populate_inventory

4
makemigrations.sh Executable file
View file

@ -0,0 +1,4 @@
#!/bin/bash -x
docker image build -f docker/Dockerfile.makemigrations -t makemigrations .
docker run -it --env-file=docker/laptop-mode-env -v $(pwd):/source makemigrations