Commit 467f86da authored by Florent Chehab's avatar Florent Chehab

fix(first launch backend container crash):

We now wait for the necessary static files to be generated before collecting the static files in the backend.

Fixes #88
parent 3cc1ee43
#!/bin/bash
# Script to make sure that assets from the frontend have been generated at least
# once so that the backend container doesn't crash on the first launch.
while [ ! -f `dirname $0`/../frontend/webpack-stats.json ]; do
echo "Waiting for frontend static files to be initialized..."
sleep 2
done
echo "Frontend staticfiles are ready (NB: not necessarly up-to-date)."
......@@ -36,10 +36,11 @@ services:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
# Run the django developpement server on image startup.
command: /bin/sh -c "cd backend && ./manage.py collectstatic --noinput && ./manage.py runserver 0.0.0.0:8000"
command: /bin/sh -c "cd backend && ./waitForFrontend.sh && ./manage.py collectstatic --noinput && ./manage.py runserver 0.0.0.0:8000"
depends_on:
# Required that the `database` service is up and running.
# Required that the `database` and `frontend` service is up and running.
- database
- frontend
# Service for the postgres database
database:
......
......@@ -48,8 +48,6 @@ Finally you can start-up all `docker` related *stuff* using the command:
make up--build
```
**When you launch the project for the first time you'll most likely have the backend container crash due to the lack of some static files. Make sure not to stop the launch process until you see `frontend_1 | ℹ 「wdm」: Compiled successfully` in the console. Then you can stop the command (`CTRL+C`) and do `make up`; you shouldn't have issues thereafter.**
You can look at the `Makefile` to have more information on that last command and the other ones that are available.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment