From fb5d0b894160b53bd100385d1b820f8e0d282291 Mon Sep 17 00:00:00 2001 From: James Polley Date: Mon, 31 Jul 2017 22:41:47 +1000 Subject: [PATCH] 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 --- docker/Dockerfile.makemigrations | 22 ++++++++++++++++++++++ docker/laptop-mode-env | 6 ++++++ make_dev_container.sh | 18 ++++++++++++++++++ makemigrations.sh | 4 ++++ 4 files changed, 50 insertions(+) create mode 100644 docker/Dockerfile.makemigrations create mode 100644 docker/laptop-mode-env create mode 100755 make_dev_container.sh create mode 100755 makemigrations.sh diff --git a/docker/Dockerfile.makemigrations b/docker/Dockerfile.makemigrations new file mode 100644 index 00000000..a529085e --- /dev/null +++ b/docker/Dockerfile.makemigrations @@ -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"] + diff --git a/docker/laptop-mode-env b/docker/laptop-mode-env new file mode 100644 index 00000000..7616c74e --- /dev/null +++ b/docker/laptop-mode-env @@ -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 diff --git a/make_dev_container.sh b/make_dev_container.sh new file mode 100755 index 00000000..17a5afab --- /dev/null +++ b/make_dev_container.sh @@ -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 diff --git a/makemigrations.sh b/makemigrations.sh new file mode 100755 index 00000000..c59c5a49 --- /dev/null +++ b/makemigrations.sh @@ -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 +