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.

149 lines
3.9 KiB

  1. Example Web Server/Site Template
  2. ================================
  3. -------------------------------------------------
  4. Git Branching
  5. -------------------------------------------------
  6. ```
  7. hotfix *--*
  8. / \
  9. master *--------------*------*----------*------------*----------*--------------
  10. \ / \ / / /
  11. release \ *---*----------*------*------------*----------*----------------
  12. \ / \ \ \ / /
  13. dev *--*--*----*----*--*--*--*---*-----*--*----*--*--*------------------
  14. \ / \ /
  15. feature *--*--* *--*--*
  16. ```
  17. -------------------------------------------------
  18. Project Layout
  19. -------------------------------------------------
  20. ### Project Working Copy
  21. ```
  22. ~/Projects/Web/example.com/ # git repo (git ignore www)
  23. |
  24. |-- docker-compose.yml
  25. |
  26. |-- service/
  27. | |
  28. | |-- docker-compose.yml
  29. |
  30. |-- www/ # git repo (git ignore build)
  31. | |
  32. | |-- Makefile
  33. | |
  34. | |-- index.pug
  35. | |
  36. | |-- build/ # git repo (if not building target on server, e.g. static GitHub pages)
  37. | | |
  38. | | |-- index.html
  39. | |
  40. | |-- config/
  41. ```
  42. ### Hosted Project Collaboration
  43. ```
  44. git@examplecodehost.com:organization/example.com.git # server config repo
  45. git@examplecodehost.com:organization/www.example.com.git # site source repo
  46. ```
  47. ### Server Deployment
  48. ```
  49. /usr/local/src/web/example.com/
  50. |
  51. |-- server/ # bare git repo for server config
  52. |
  53. |-- www/ # bare git repo for site build files (or optionally site source files if server builds project)
  54. |
  55. |-- build/ # optional bare git repo for build files if server builds project automatically
  56. ```
  57. Git branches are checked out to different worktrees to be served:
  58. ```
  59. /srv/dev/example.com/ # dev branch server config
  60. |
  61. |-- docker-compose.yml
  62. |
  63. |-- www/ # dev branch built site
  64. /srv/beta/example.com/ # release branch server config
  65. |
  66. |-- docker-compose.yml
  67. |
  68. |-- www/ # release branch built site
  69. /srv/prod/example.com/ # master branch server config
  70. |
  71. |-- docker-compose.yml
  72. |
  73. |-- www/ # master branch built site
  74. ```
  75. Dev, beta, and prod could all be on different servers if appropriate.
  76. -------------------------------------------------
  77. Server Groups and Directory Permissions
  78. -------------------------------------------------
  79. Add your user (on the server) to the srv group. Set directory permissions
  80. ```
  81. # chown root:srv .
  82. # chmod g+ws .
  83. # setfacl -d -m g::rwx .
  84. ```
  85. for all relevant directories (newly created subdirectories should inherit permissions):
  86. ```
  87. /usr/local/src/web/example.com/
  88. /usr/local/src/web/example.com/server/
  89. /usr/local/src/web/example.com/www/
  90. /usr/local/src/web/example.com/build/
  91. /srv/dev/example.com/
  92. /srv/dev/example.com/www/
  93. /srv/beta/example.com/
  94. /srv/beta/example.com/www/
  95. /srv/prod/example.com/
  96. /srv/prod/example.com/www/
  97. ```
  98. In upstream bare repo directories (e.g. `webserver:/usr/local/src/web/example.com/www/`), run:
  99. ```
  100. # git init --bare --shared=group
  101. # git config receive.denyCurrentBranch updateInstead
  102. # git config receive.denyNonFastForwards false
  103. # git config core.sharedRepository true # if needed because of missing init option
  104. ```
  105. In working copy repos, set upstream and push branches to new bare repos, then in
  106. the bare repos run:
  107. ```
  108. # git worktree add /srv/prod/example.com/www master
  109. # git worktree add /srv/beta/example.com/www release
  110. # git worktree add /srv/dev/example.com/www dev
  111. ```
  112. Maybe needed if above permissions weren't set correctly:
  113. ```
  114. # chmod -R g+w .
  115. # chmod g+w /srv/*/example.com/www
  116. # chown -R root:srv .
  117. # chmod -R g+swX .
  118. # chown root:srv /srv/prod/example.com/www
  119. # chmod g+swX /srv/prod/example.com/www
  120. # chown root:srv /srv/beta/example.com/www
  121. # chmod g+swX /srv/beta/example.com/www
  122. # chown root:srv /srv/dev/example.com/www
  123. # chmod g+swX /srv/dev/example.com/www
  124. ```