Changeset - fb5d0b894160
[Not reviewed]
0 0 4
James Polley - 7 years ago 2017-08-28 06:54:34
jp@jamezpolley.com
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
4 files changed with 50 insertions and 0 deletions:
0 comments (0 inline, 0 general)
docker/Dockerfile.makemigrations
Show inline comments
 
new file 100644
 
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"]
 

	
docker/laptop-mode-env
Show inline comments
 
new file 100644
 
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
make_dev_container.sh
Show inline comments
 
new file 100755
 
#!/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
makemigrations.sh
Show inline comments
 
new file 100755
 
#!/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
 

	
0 comments (0 inline, 0 general)