Changeset - af5fec11ff33
[Not reviewed]
2 5 0
James Polley - 7 years ago 2017-10-04 09:43:01
jp@jamezpolley.com
Utilise multi-stage docker build for consistent dev/prod base

* developers can use --target symposion_dev to get a responsive site
that reads from their homedir and reacts to changed files instantly
* without a specified target the default is to build the prod image,
which is identical except for running uwsgi instead of the django
built-in server
* Enable debug when running in a developer's test environment
* Remove the makemigrations script and dockerfile
7 files changed with 18 insertions and 39 deletions:
0 comments (0 inline, 0 general)
.dockerignore
Show inline comments
 
.git
 
ve
 
symposion-fixtures
 

	
README.rst
Show inline comments
...
 
@@ -66,6 +66,7 @@ If you make changes to the data model, you'll need to run "manage.py
 
makemigrations" to create a matching migration file. If you're on a
 
mac, or a system without python3, this can be difficult. In such a
 
case, the ``makemigrations.sh`` script takes advantaged of a docker
 
container that's slightly modified, and runs the makemigration action
 
on the files in your working directory.
 
mac, or a system without python3, this can be difficult.
 

	
 
In such a case, you can use the above script to make and run a dev
 
container; then::
 
    docker exec -it symposion ./manage.py makemigrations
 

	
docker/Dockerfile
Show inline comments
 
FROM python:3.6
 

	
 
FROM python:3.6 as symposion_base
 

	
...
 
@@ -43,2 +42,8 @@ RUN set -x \
 
       python manage.py collectstatic --noinput -l -v 0
 

	
 
FROM symposion_base as symposion_dev
 
VOLUME /app/symposion_app
 
CMD ["./manage.py", "runserver", "-v3", "0.0.0.0:8000"]
 

	
 
FROM symposion_base as symposion_prod
 
CMD ["/usr/local/bin/uwsgi", "--http-socket", "0.0.0.0:8000", "--wsgi-file", "pinaxcon/wsgi.py"]
docker/Dockerfile.makemigrations
Show inline comments
 
deleted file
docker/laptop-mode-env
Show inline comments
...
 
@@ -6,2 +6,3 @@ GOOGLE_APPLICATION_CREDENTIALS=/dev/null
 
DATABASE_URL=sqlite:////tmp/symposion.sqlite
 
SYMPOSION_DEV_MODE=LAPTOP
...
 
\ No newline at end of file
 
SYMPOSION_DEV_MODE=LAPTOP
 
SYMPOSION_APP_DEBUG=1
...
 
\ No newline at end of file
make_dev_container.sh
Show inline comments
...
 
@@ -4,6 +4,6 @@ CONTAINER_NAME=${1:-symposion_app}
 

	
 
docker image build -f docker/Dockerfile -t ${CONTAINER_NAME} .
 
docker image build -f docker/Dockerfile -t ${CONTAINER_NAME} --target symposion_dev .
 
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 create --env-file docker/laptop-mode-env -p 28000:8000 -v $(pwd):/app/symposion_app --name symposion ${CONTAINER_NAME}
 
docker container start symposion
makemigrations.sh
Show inline comments
 
deleted file
0 comments (0 inline, 0 general)