Simplify migrations and static collection

Migrations and static assets collection are no longer performed every
time we build an image. Instead, they are run on command.
This commit is contained in:
Régis Behmo 2017-07-19 09:42:42 +02:00
parent 199626c434
commit 12e08d7c5d
4 changed files with 10 additions and 16 deletions

4
Makefile Normal file
View File

@ -0,0 +1,4 @@
migrate:
docker-compose run lms ./manage.py lms migrate --settings=production
assets:
docker-compose run lms paver update_assets lms --settings=production

View File

@ -17,6 +17,11 @@ Create necessary data folders:
The LMS will be reachable at the following url: [http://openedx.localhost](http://openedx.localhost).
On the first run you will need to migrate the database and collect static assets:
make migrate
make assets
## Development tips & tricks
Open a bash in the lms:

View File

@ -35,9 +35,6 @@ services:
lms:
build:
context: ./lms
args:
RUN_MIGRATIONS: 1
COLLECT_STATIC: 1
volumes:
- ./data/lms/course_static:/openedx/course_static
- ./data/lms/data:/openedx/data

View File

@ -53,16 +53,4 @@ ENV SERVICE_VARIANT lms
# Run server
EXPOSE 8000
# Migrate
ARG RUN_MIGRATIONS=0
ENV RUN_MIGRATIONS ${RUN_MIGRATIONS}
# Collect static assets
ARG COLLECT_STATIC=0
ENV COLLECT_STATIC ${COLLECT_STATIC}
# TODO Here we wait until mysql and mongodb become available but it's a terrible solution
CMD sleep 5 && \
if [ "$RUN_MIGRATIONS" = "1" ] ; then ./manage.py lms migrate --settings=production ; fi && \
if [ "$COLLECT_STATIC" = "1" ] ; then paver update_assets lms --settings=production ; fi && \
gunicorn --name lms --bind=0.0.0.0:8000 --max-requests=1000 lms.wsgi:application
CMD gunicorn --name lms --bind=0.0.0.0:8000 --max-requests=1000 lms.wsgi:application