docker-entrypoint.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/sh
  2. set -e
  3. if [ ! -f "/homehub_workspace/package.json" ]; then
  4. echo "$0: Initializing the workspace at /homehub_workspace"
  5. (
  6. cd /;
  7. /homehub_var/virtualenv/bin/cookiecutter --no-input -f -s /homehub-workspace;
  8. )
  9. fi
  10. if [ -d "/homehub_workspace/docker-entrypoint.d/" ]; then
  11. echo "$0: Executing setup scripts at /homehub_workspace/docker-entrypoint.d"
  12. find "/homehub_workspace/docker-entrypoint.d/" -follow -type f -print | sort -n | while read -r f; do
  13. case "$f" in
  14. *.sh)
  15. if [ -x "$f" ]; then
  16. echo "$0: Executing $f";
  17. "$f"
  18. fi
  19. ;;
  20. *) ;;
  21. esac
  22. done
  23. fi
  24. (
  25. echo "$0: Installing backend dependencies at /homehub_workspace";
  26. cd /homehub_workspace;
  27. /homehub_var/virtualenv/bin/pip install -r requirements.txt;
  28. )
  29. SHOULD_BUILD_FRONTEND=1
  30. if [ -f "/homehub_var/stamp_frontend.txt" ]; then
  31. SHOULD_BUILD_FRONTEND=`sha256sum -s -c "/homehub_var/stamp_frontend.txt"; echo $?`
  32. fi
  33. if [ $SHOULD_BUILD_FRONTEND -eq 1 ]; then
  34. echo "$0: Building and stamping the frontend at /homehub_workspace"
  35. (
  36. cd /homehub_workspace;
  37. yarn --modules-folder $YARN_MODULES_FOLDER install --prod --pure-lockfile;
  38. yarn --modules-folder $YARN_MODULES_FOLDER run webpack-cli;
  39. sha256sum "/homehub_workspace/package.json" "/homehub_workspace/settings.js" > "/homehub_var/stamp_frontend.txt";
  40. )
  41. fi
  42. exec "$@"