From 12e08d7c5d21f1e4b3655288ce8847fd7e71afcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Behmo?= Date: Wed, 19 Jul 2017 09:42:42 +0200 Subject: [PATCH] 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. --- Makefile | 4 ++++ README.md | 5 +++++ docker-compose.yml | 3 --- lms/Dockerfile | 14 +------------- 4 files changed, 10 insertions(+), 16 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..43741a0 --- /dev/null +++ b/Makefile @@ -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 diff --git a/README.md b/README.md index 06f3db5..5203eb7 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/docker-compose.yml b/docker-compose.yml index b12934f..a18c998 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 diff --git a/lms/Dockerfile b/lms/Dockerfile index af5c639..1027f80 100644 --- a/lms/Dockerfile +++ b/lms/Dockerfile @@ -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