entrypoint.sh 800 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/sh
  2. #
  3. set -e
  4. REQUIRE_INIT_OPS=false
  5. # env check
  6. if [ -z $REGISTRY_SERVER ]; then
  7. echo 'Please set REGISTRY_SERVER by -e REGISTRY_SERVER=<docker registry server>'
  8. exit 1
  9. fi
  10. # init db
  11. if [ ! -d /var/lib/mysql/mysql ]; then
  12. echo 'Initializing db, please wait ...'
  13. REQUIRE_INIT_OPS=true
  14. /bin/sh /scripts/init_db.sh
  15. fi
  16. # init nginx
  17. if [ ! -d /run/nginx ]; then
  18. mkdir -p /run/nginx
  19. chown -R nginx.nginx /run/nginx
  20. fi
  21. # init config
  22. if [ ! -f /init_config.lock ]; then
  23. /bin/sh /scripts/init_config.sh
  24. touch /init_config.lock
  25. fi
  26. cd /spug/spug_api
  27. nginx
  28. nohup /usr/bin/mysqld_safe --datadir=/var/lib/mysql --user=root &
  29. sleep 2
  30. if [ $REQUIRE_INIT_OPS == true ]; then
  31. /usr/bin/python3 /scripts/init_spug.py
  32. fi
  33. gunicorn --threads=32 main:app -b 0.0.0.0:3000