Changeset - ddae8d91f682
[Not reviewed]
0 4 0
James Polley - 6 years ago 2018-06-06 02:20:06
jp@jamezpolley.com
Improved handling of static/build and css generation

When the container is mounted, the local contents of . obscure
/app/symposion_app in the image.

Generally speaking, this is handy for development, as it means that
local changes are detected and used immediately without needing to
restart the container.

However, it breaks in the specific case of the sass->css
generation. Prior to this change, the css is generated only after the
first time a page is hit. The generated file is placed in
static/build; however, due to the obscuration, this generated file
isn't visible to the running process.

The next time the container is built, the pre-existing static/build
directory is copied into the container as it's being built; then,
later, that version is what gets served.

This change adds the needed libraries to pre-generate the css as part
of the image build, and runs compilescss to do this, prior to the
collectstatic step.

It also adds a second collectstatic into the make_dev_container
script, so that the visible static/build directory should ahve the
same contents as the obscured static/build directory. It also expands
the .dockerignore file to make sure these files aren't copied into the
image in future.

I'm not sure if this is the right thing to do, as changes to this
directory will be ignored, which could be confusing. Perhaps never
being able to see these generated files is better?
4 files changed with 15 insertions and 2 deletions:
0 comments (0 inline, 0 general)
.dockerignore
Show inline comments
 
.git
 
symposion-tools
 

	
 
docker
 
static/build
 
*.sh
 
TODO
 
dev-env.sh
 
.gitlab-ci.yml
docker/Dockerfile
Show inline comments
...
 
@@ -33,6 +33,9 @@ COPY . /app/symposion_app
 
WORKDIR /app/symposion_app
 
RUN set -x \
 
    && pip install -r vendored_requirements.txt -c /reqs/constraints.txt
 
RUN set -x \
 
    && DJANGO_SECRET_KEY=1234 STRIPE_PUBLIC_KEY=1234 STRIPE_SECRET_KEY=1234 \
 
       DATABASE_URL="sqlite:////dev/null" python manage.py compilescss
 
RUN set -x \
 
    && DJANGO_SECRET_KEY=1234 STRIPE_PUBLIC_KEY=1234 STRIPE_SECRET_KEY=1234 \
 
       DATABASE_URL="sqlite:////dev/null" \
make_dev_container.sh
Show inline comments
...
 
@@ -13,6 +13,10 @@ docker container stop symposion
 
docker container rm symposion
 
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
 
## When we started the container and mounted . into /app/symposion_app, it hides the static/build directory
 
## As a kludge, re-run collectstatic to recreate it
 
## Possible alternative here: don't mount all of ., just mount the bits that we'd live to have update live
 
docker exec symposion ./manage.py collectstatic --noinput -v 0
 
docker exec symposion ./manage.py migrate
 
docker exec symposion ./manage.py loaddata ./fixtures/{conference,sites,sitetree,proposal_base,flatpages}.json
 
docker exec symposion ./manage.py create_review_permissions
requirements.txt
Show inline comments
 
Django>=1.11
 
pinax-theme-bootstrap==7.3.0
 
pinax-theme-bootstrap~=7.10.0
 
pinax-eventlog==1.1.1
 
django-formset-js==0.5.0
 
dj-static==0.0.6
...
 
@@ -48,3 +48,4 @@ django-waffle>=0.12.0
 
# SASS Compiler and template tags
 
libsass==0.14.5
 
django-sass-processor==0.7
 
django-compressor==2.2
0 comments (0 inline, 0 general)