Source code for the modding-openmw.com website https://modding-openmw.com/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

192 lines
6.6 KiB

5 months ago
  1. proj_dir := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
  2. .DEFAULT_GOAL := server
  3. PORT ?= 8666
  4. host_check:
  5. ifndef HOSTS
  6. @echo "\n\033[31mPLEASE PROVIDE THE '\033[91mHOSTS\033[31m' VARIABLE!\nUSAGE: \033[91mmake TARGET HOSTS=some_hosts_or_host_group\033[0m\n"
  7. @exit 1
  8. endif
  9. get-versions:
  10. @echo PRODUCTION:
  11. @http --print b https://modding-openmw.com/_stat/
  12. @echo STAGING:
  13. @http --print b https://staging.modding-openmw.com/_stat/
  14. @echo BETA:
  15. @http --print b https://beta.modding-openmw.com/_stat/
  16. clean:
  17. /bin/rm -fr *.sqlite3 src && for d in $$(find . -name __pycache__); do rm -rf $${d}; done
  18. compose-up:
  19. docker-compose up --build
  20. docker-reset:
  21. docker rm momw_psql_1
  22. docker volume rm momw_psql-data
  23. migrate:
  24. $(proj_dir)/momw/manage.py migrate
  25. makemigrations:
  26. $(proj_dir)/momw/manage.py makemigrations
  27. shell:
  28. $(proj_dir)/momw/manage.py shell
  29. smtpd:
  30. python3 -m smtpd -n -c DebuggingServer localhost:1025
  31. refreshdb:
  32. sudo -u momwdb dropdb momwdb && sudo -u momwdb createdb momwdb
  33. seeddb:
  34. $(proj_dir)/bin/seed_db.py
  35. reset: clean refreshdb migrate seeddb
  36. server:
  37. $(proj_dir)/momw/manage.py runserver 0.0.0.0:$(PORT)
  38. pip-requirements:
  39. python3 -m pip install --user -r requirements.txt
  40. start-xvfb-ci:
  41. $(proj_dir)/bin/start_xvfb.sh
  42. test-black:
  43. ifneq (, $(shell which black 2>/dev/null))
  44. black --check $(proj_dir)
  45. else
  46. @echo black executable not found!
  47. endif
  48. test-flake8:
  49. find $(proj_dir) -type f -name "*.py" | xargs flake8 --verbose
  50. test-dropdb:
  51. sudo -u momwdb dropdb test_momwdb || echo test db is gone
  52. test-chroniko:
  53. $(proj_dir)/momw/manage.py test chroniko.tests
  54. test-media:
  55. $(proj_dir)/momw/manage.py test media.tests
  56. test-momw:
  57. $(proj_dir)/momw/manage.py test momw.tests
  58. test-utilz:
  59. $(proj_dir)/momw/manage.py test utilz.tests
  60. test-djangotests: test-chroniko test-momw test-utilz
  61. ifndef SKIPTESTS
  62. test: test-black test-flake8 test-dropdb test-djangotests
  63. else
  64. test:
  65. @echo Skipped tests due to the presence of the SKIPTESTS env var!
  66. endif
  67. django: host_check test
  68. cd ../playbooks && \
  69. ansible-playbook momw.yml --extra-vars "control_hosts=$(HOSTS) \
  70. control_msg='Momw Django App Setup' \
  71. control_user=root \
  72. django_db_migrate=true \
  73. django_db_seed=true \
  74. django_start=true \
  75. django_sync_code=true \
  76. django_drop_db=true" \
  77. --vault-password-file ${CURDIR}/auth
  78. django-migrate: host_check test
  79. cd ../playbooks && \
  80. ansible-playbook momw.yml --extra-vars "control_hosts=$(HOSTS) \
  81. control_msg='Run Momw Django db migrations' \
  82. control_user=$(CONTROL_USER) \
  83. db_migrate=true" \
  84. --tags ircspam,migration
  85. django-seeddb: host_check test
  86. cd ../playbooks && \
  87. ansible-playbook momw.yml --extra-vars "control_hosts=$(HOSTS) \
  88. control_msg='Momw Django database seed' \
  89. control_user=root \
  90. django_db_migrate=true \
  91. django_db_seed=true" \
  92. --tags ircspam,django_seeddb
  93. django-resetdb: host_check test ## Reset the remote database with new data
  94. cd ../playbooks && \
  95. ansible-playbook momw.yml --extra-vars "control_hosts=$(HOSTS) \
  96. control_msg='Momw Django database reset' \
  97. control_user=root \
  98. django_db_migrate=true \
  99. django_db_seed=true \
  100. django_drop_db=true" \
  101. --tags ircspam,django_seeddb,django_resetdb \
  102. --vault-password-file ${CURDIR}/auth
  103. django-warmcache: host_check
  104. cd ../playbooks && \
  105. ansible-playbook momw.yml --extra-vars "control_hosts=$(HOSTS) \
  106. control_msg='Momw Django cache warm' \
  107. control_user=root \
  108. django_warmcache=true" \
  109. --tags ircspam,warmcache
  110. sync: host_check test
  111. cd ../playbooks && \
  112. ansible-playbook momw.yml --extra-vars "control_hosts=$(HOSTS) \
  113. control_msg='Momw Code Sync & Restart' \
  114. control_user=root \
  115. django_git=true \
  116. django_sync_code=true" \
  117. --tags ircspam,django_sync
  118. web: host_check test
  119. cd ../playbooks && \
  120. ansible-playbook momw.yml --extra-vars "control_hosts=$(HOSTS) \
  121. control_msg='Momw webserver config' \
  122. control_user=root" \
  123. --tags django_webserver
  124. memcached-restart: host_check
  125. cd ../playbooks && \
  126. ansible-playbook momw.yml --extra-vars "control_hosts=$(HOSTS) \
  127. control_msg='memcached service restart' \
  128. control_user=root \
  129. memcached_restart=true" \
  130. --tags ircspam,memcached
  131. # ffmpeg -i input.flv -codec copy output.mp4
  132. # ffmpeg -i input.mp4 -ss 00:00:02 -to 00:15:40 -c copy output.mp4
  133. add-watermark-to-video:
  134. ifndef INFILE
  135. @echo YOU NEED TO PROVIDE AN 'INFILE' e.g. INFILE=foo make add-watermark-to-video!
  136. @exit 1
  137. endif
  138. ifndef OUTFILE
  139. @echo YOU NEED TO PROVIDE AN 'OUTFILE' e.g. OUTFILE=foo make add-watermark-to-video!
  140. @exit 1
  141. endif
  142. ffmpeg -i $(INFILE) -i $(proj_dir)/momw/static/onesixth-watermark.png -filter_complex "overlay=20:20" -max_muxing_queue_size 1024 $(OUTFILE)
  143. add-watermark-to-image:
  144. ifndef INFILE
  145. @echo YOU NEED TO PROVIDE AN 'INFILE' e.g. INFILE=foo make add-watermark-to-image!
  146. @exit 1
  147. endif
  148. ifndef OUTFILE
  149. @echo YOU NEED TO PROVIDE AN 'OUTFILE' e.g. OUTFILE=foo make add-watermark-to-image!
  150. @exit 1
  151. endif
  152. ifndef COLOR
  153. convert $(INFILE) -gravity NorthWest -pointsize 40 -fill '#fffdc3' -annotate +20+20 "Modding-OpenMW.com" $(OUTFILE)
  154. else
  155. convert $(INFILE) -gravity NorthWest -pointsize 40 -fill "$(COLOR)" -annotate +20+20 "Modding-OpenMW.com" $(OUTFILE)
  156. endif