Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. #! /bin/sh
  2. #
  3. if [ ! -f "${PWD}/.env" ]; then
  4. echo "missing env file in ${PWD}"
  5. exit 1
  6. fi
  7. set -a
  8. . "${PWD}/.env"
  9. . "${PWD}/env_files/certs.env"
  10. set +a
  11. mkdir -p "/tmp/${PREFIX}"
  12. echo "Setting up docker volumes"
  13. docker volume create "${PREFIX}-db"
  14. docker volume create "${PREFIX}-traefik-certs"
  15. docker volume create "${PREFIX}-traefik-dynamic"
  16. docker volume create "${PREFIX}-traefik-logs"
  17. docker volume create "${PREFIX}-traefik-static"
  18. docker volume create "${PREFIX}-webroot"
  19. docker volume create wp-cli-cache
  20. echo "Copying SSL certificates to traefik volume"
  21. if [ ! -f "${SSL_CRT_LOCATION}/${SSL_CRT_NAME}" ] || [ ! -f "${SSL_KEY_LOCATION}/${SSL_KEY_NAME}" ]; then
  22. echo "Missing SSL key or cert file"
  23. exit 1
  24. fi
  25. docker run \
  26. --rm \
  27. --volume "${PREFIX}-traefik-certs":/certs \
  28. --volume "${SSL_CRT_LOCATION}":/source \
  29. ubuntu \
  30. cp "/source/${SSL_CRT_NAME}" /certs
  31. docker run \
  32. --rm \
  33. --volume "${PREFIX}-traefik-certs":/certs \
  34. --volume "${SSL_KEY_LOCATION}":/source \
  35. ubuntu \
  36. cp "/source/${SSL_KEY_NAME}" /certs
  37. echo "Generating traefik configuration files (ssl.yml and middlewares.yml)"
  38. cat << EOF > /tmp/${PREFIX}/ssl.yml
  39. ---
  40. tls:
  41. stores:
  42. default:
  43. defaultCertificate:
  44. certFile: /certs/${SSL_CRT_NAME}
  45. keyFile: /certs/${SSL_KEY_NAME}
  46. EOF
  47. cat << EOF > /tmp/${PREFIX}/middlewares.yml
  48. ---
  49. http:
  50. middlewares:
  51. https-redirect:
  52. redirectscheme:
  53. scheme: https
  54. permanent: true
  55. EOF
  56. docker run \
  57. --rm \
  58. --volume "/tmp/${PREFIX}":/source \
  59. --volume "${PREFIX}-traefik-dynamic":/destination \
  60. ubuntu \
  61. cp /source/ssl.yml /source/middlewares.yml /destination
  62. echo "Generating traefik static configuration"
  63. cat << EOF > /tmp/${PREFIX}/static.yml
  64. ---
  65. api:
  66. dashboard: true
  67. entrypoints:
  68. http:
  69. address: :80
  70. https:
  71. address: :443
  72. log:
  73. filepath: /logs/traefik.log
  74. level: debug
  75. providers:
  76. docker:
  77. exposedbydefault: false
  78. file:
  79. directory: /etc/traefik/dynamic
  80. watch: true
  81. EOF
  82. docker run \
  83. --rm \
  84. --volume "/tmp/${PREFIX}":/source \
  85. --volume "${PREFIX}-traefik-static":/destination \
  86. ubuntu \
  87. cp /source/static.yml /destination/traefik.yml
  88. docker compose up -d app
  89. while ! docker ps -q -f name="${PREFIX}-app"; do
  90. echo "Waiting for the web container to be up and running..."
  91. sleep 1
  92. done
  93. docker compose up -d db
  94. while ! docker ps -q -f name="${PREFIX}-db"; do
  95. echo "Waiting for the db container to be up and running..."
  96. sleep 1
  97. done
  98. while ! docker exec "${PREFIX}-app" /bin/sh -c "mysqladmin ping -h ${PREFIX}-db -P 3306 --protocol=tcp -u user -puser --silent"; do
  99. echo "Waiting for the mysql server in the db container to be up and running and reachable from the app container..."
  100. sleep 1
  101. done
  102. echo "Downloading WordPress core"
  103. docker exec --user www-data "${PREFIX}-app" /bin/sh -c "
  104. wp core download \
  105. --locale=${WP_LOCALE} \
  106. --path=/var/www/html \
  107. --version=${WP_VERSION}"
  108. echo "Creating WordPress config"
  109. docker exec --user www-data "${PREFIX}-app" /bin/sh -c '
  110. wp config create \
  111. --dbhost='"${PREFIX}-db"' \
  112. --dbname='"${DB_NAME}"' \
  113. --dbpass='"${DB_USER_PASSWORD}"' \
  114. --dbuser='"${DB_USER}"' \
  115. --force \
  116. --path=/var/www/html \
  117. --skip-check \
  118. --extra-php <<EXTRA-PHP
  119. if (isset(\$_SERVER["HTTP_X_FORWARDED_PROTO"]) && \$_SERVER["HTTP_X_FORWARDED_PROTO"] == "https") \$_SERVER["HTTPS"]="on";
  120. EXTRA-PHP
  121. '
  122. echo "Installing WordPress core"
  123. docker exec --user www-data "${PREFIX}-app" /bin/sh -c "
  124. wp core install \
  125. --admin_email=no@mail.com \
  126. --admin_password=${WP_ADMIN_PASSWORD} \
  127. --admin_user=${WP_ADMIN_USERNAME} \
  128. --path=/var/www/html \
  129. --skip-email \
  130. --title=${PREFIX} \
  131. --url=${WP_DEFAULT_PROTOCOL}://${APP_URL}"
  132. echo "Installing WordPress "${WP_THEME}" theme"
  133. docker exec --user www-data "${PREFIX}-app" /bin/sh -c "
  134. wp theme install ${WP_THEME} \
  135. --activate \
  136. --path=/var/www/html"
  137. docker compose up -d adminer
  138. docker compose up -d traefik