From 3581421650f767c045f6c0df2ac78c715dac0f46 Mon Sep 17 00:00:00 2001 From: Jay Rogers Date: Fri, 9 Aug 2024 14:02:02 -0500 Subject: [PATCH] Release/v2.0.0 (#89) * Fixed shell check stuff * Change to stable CLI for PHP * Removed old code * Remove GHA templates * Removed templates from repo * Removed unused variable * WIP of Spin new refactor * Working init * Simplified code * Fix default var * Added cleanup * Fixed reference * Put quotes on variable * Added check for default branch * Improve variable setting * Centralized download function * Working init * Fix spelling error * Working new and init * Remove debug * chore: Update existing file warning message formatting * Fix issue with 'new.sh' script not removing repository arguments * Remove templates * Fix echo bug * chore: Update SPIN_USER_ID and SPIN_GROUP_ID assignment * feat: Add 'deploy' action to spin script * Centralized function * Centralized funciton * Set to deploy * Organized functions * feat: Add 'mkpasswd' command to spin script * feat: Add Docker Compose file support to deploy.sh and provision.sh * chore: Update ansible-galaxy collection to serversideup.spin * feat: Update ansible-galaxy collection to serversideup.spin * Working SSH upload * Working deploy * Zero downtime deployments working * Reset download * Remove templates * chore: Refactor deploy.sh to improve cleanup_registry function * feat: Add support for dynamic Docker Compose files in deploy.sh * chore: Add template usage instructions to init.sh * chore: Update provision.sh flag for upgrade to use uppercase 'U' * chore: Remove unused variable in deploy.sh * chore: Update init.sh to include template usage instructions * chore: Update ansible-galaxy collection installation command * chore: Update SPIN_ANSIBLE_IMAGE to version 2.16-alpine-3.19 * chore: Update provision command to support Ubuntu 22.04+ servers * chore: Update server requirements to include Ubuntu 22.04+ support * chore: Update provision command to support Ubuntu 22.04+ servers and add upgrade flag * chore: Update provision command to support Ubuntu 22.04+ servers and add upgrade flag * chore: Update provision command to support Ubuntu 22.04+ servers and add upgrade flag * Fixed reference * chore: Add new command reference for "spin deploy" * Ensure new line always exists * chore: Update .gitignore and .dockerignore to exclude .vault-password file * Clean up and refactor * chore: Set SPIN_ACTION to "new" when calling install.sh on a template * Set comment * chore: Refactor run_ansible function to use an array for additional docker arguments * chore: Update ansible-galaxy collection installation command to use quotes for collection name * Added vault password support * Refactor get_ansible_variable function to use separate function for ansible vault arguments * Refactor deploy and provision scripts to use check_galaxy_pull function * Refactor deploy and provision scripts to use check_galaxy_pull function * Refactor deploy.sh to use ansible vault arguments in get_hosts_from_ansible function * chore: Refactor SSH tunnel creation in deploy.sh * Rely on the template to set SPIN_PROJECT_DIRECTORY * Some suggestions for the deploy command (#82) * Some suggestions - Read the .env file if there is one. This would make it easier to set certain variables on a per project basis. - Make reading the configuration files dynamic. This way you don't need a .infrastructure folder if you haven't defined any config key. Only caveat is that it will use the file name to generate the environment variable. So ``` configs: traefik: name: 'traefik-${SPIN_TRAEFIK_CONFIG_MD5_HASH}.yml' file: ./.infrastructure/conf/traefik/prod/traefik.yml ``` Would become: ``` configs: traefik: name: 'traefik-${SPIN_TRAEFIK_YML_CONFIG_MD5_HASH}.yml' file: ./.infrastructure/conf/traefik/prod/traefik.yml ``` - Remove the requirement for a Docker image. This would make it easier to run specific docker stacks with only redis or traefik * Set environment variables to SPIN_MD5_HASH_{{config-filename}} * Quote variable --------- Co-authored-by: Jay Rogers * Quoted variables * Fix comment * Added docs how to create your own Spin template * Added image * Updated docs about official laravel template * docs: Remove deprecated guide on using mkpasswd to generate user passwords * chore: Update server preparation documentation * Update Spin description to emphasize consistent configuration across environments * docs: Update Spin description and deployment options * Remove version * Bump to =8.3 in docs * docs: Update Spin deployment options and descriptions * docs: Update Spin deployment options and descriptions * Changed Git Clones from HTTPS to SSH * chore: Update default registry port in deploy script * Updated docs * docs: Update deployment documentation for using different .env files per environment * chore: Load environment variables from .env file for the target environment * Added `spin ps` * chore: Add post-install script for executing additional commands after template installation * chore: Update temporary template source directory variable names * chore: Build and push Docker images for each Dockerfile in the project directory * Updated function to line_in_file * Fixed link * Ignore spin files * chore: Update Docker image name to lowercase for consistency * Added error checking * chore: Refactor deploy.sh script for improved readability and maintainability * Remove debug * chore: Set SPIN_APP_DOMAIN based on APP_URL in deploy script * Remove debug * Refactor deploy.sh script for improved readability and maintainability * chore: Update run.sh script to disable automations and S6 logging * Refactor sed_inplace function to escape forward slashes in the replacement string * Added further action * Improved DX in output * chore: Update installation guide to use "Prerequisites" instead of "Pre-requisites" * Updated hero * chore: Update MarketingServers.vue to improve infrastructure control and ownership * Exit if no dockerfiles found * chore: Fix missing newline at end of file in version.sh * Updated GitHub Actions to be accurate * chore: Refactor line_in_file function to use 'action' instead of 'mode' * Refactor line_in_file function to use 'action' instead of 'mode' * Refactor line_in_file function to use 'action' instead of 'mode' * Removed demo until we get an updated one * Removed site previews via GitHub Actions * Changed instruction --------- Co-authored-by: Nick Retel --- .../action_marketing-site-preview.yml | 14 - .../action_marketing-site-publish.yml | 14 - .../workflows/service_deploy-static-site.yml | 48 -- README.md | 5 - bin/spin | 33 +- docs/components/content/Column.vue | 2 +- docs/components/content/FeatureGrid.vue | 2 +- docs/components/content/MarketingGrid.vue | 2 +- docs/components/content/MarketingHero.vue | 2 +- docs/components/content/MarketingServers.vue | 2 +- .../docs/1.getting-started/2.prerequisites.md | 92 --- docs/content/docs/1.index.md | 2 +- .../1.install-macos.md | 0 .../2.install-windows.md | 0 .../3.install-linux.md | 2 +- .../4.install-composer.md | 0 .../5.install-npm-yarn.md | 0 .../2.project-templates/1.laravel-basic.md | 59 ++ .../docs/2.project-templates/2.nuxt.md | 25 + .../3.create-your-own-template.md | 112 +++ .../1.how-spin-works.md | 22 +- .../2.add-spin-to-an-existing-project.md | 32 +- .../3.create-a-new-project-with-spin.md | 77 ++ .../3.preparing-your-servers-for-spin.md | 99 ++- .../4.run-a-simple-deployment.md | 64 ++ .../3.guide/1.create-a-new-laravel-project.md | 42 - ...owntime-deployments-with-github-actions.md | 257 ------- ...ing-mkpasswd-to-generate-user-passwords.md | 59 -- ...owntime-deployments-with-github-actions.md | 46 ++ .../2.generating-a-secure-deployment-key.md} | 0 .../3.adding-other-services.md} | 40 +- .../docs/4.command-reference/deploy.md | 136 ++++ .../docs/4.command-reference/mkpasswd.md | 43 ++ docs/content/docs/4.command-reference/new.md | 31 +- .../docs/4.command-reference/provision.md | 10 +- docs/content/docs/4.command-reference/ps.md | 23 + docs/content/docs/4.command-reference/up.md | 3 + .../spin-new-community-template.png | Bin 0 -> 86710 bytes .../spin-official-laravel-template.png | Bin 0 -> 16634 bytes .../docs/getting-started/server-dns.png | Bin 0 -> 51182 bytes lib/actions/deploy.sh | 254 ++++++ lib/actions/init.sh | 292 ++----- lib/actions/mkpasswd.sh | 4 + lib/actions/new.sh | 42 +- lib/actions/provision.sh | 53 +- lib/actions/ps.sh | 4 + lib/actions/run.sh | 2 +- lib/actions/update.sh | 5 +- lib/actions/vault.sh | 18 +- lib/actions/version.sh | 2 +- lib/functions.sh | 726 +++++++++++++++--- templates/common/.dockerignore.lineinfile | 3 - templates/common/.gitignore.lineinfile | 1 - .../conf/spin/collections/.gitignore | 2 - .../.infrastructure/volume_data/.gitignore | 2 - templates/laravel/.github/workflows/README.md | 17 - .../workflows/action_deploy-production.yml | 64 -- .../service_docker-build-and-publish.yml | 73 -- .../dev/certificates/local-dev-key.pem | 51 -- .../traefik/dev/certificates/local-dev.pem | 38 - .../conf/traefik/dev/traefik-certs.yml | 11 - .../conf/traefik/dev/traefik.yml | 30 - .../conf/traefik/prod/traefik.yml | 70 -- templates/laravel/Dockerfile | 47 -- templates/laravel/docker-compose.ci.yml | 37 - templates/laravel/docker-compose.dev.yml | 74 -- templates/laravel/docker-compose.prod.yml | 113 --- templates/laravel/docker-compose.yml | 15 - 68 files changed, 1742 insertions(+), 1708 deletions(-) delete mode 100644 .github/workflows/action_marketing-site-preview.yml delete mode 100644 .github/workflows/action_marketing-site-publish.yml delete mode 100644 .github/workflows/service_deploy-static-site.yml delete mode 100644 docs/content/docs/1.getting-started/2.prerequisites.md rename docs/content/docs/{2.installation => 1.installation}/1.install-macos.md (100%) rename docs/content/docs/{2.installation => 1.installation}/2.install-windows.md (100%) rename docs/content/docs/{2.installation => 1.installation}/3.install-linux.md (99%) rename docs/content/docs/{2.installation => 1.installation}/4.install-composer.md (100%) rename docs/content/docs/{2.installation => 1.installation}/5.install-npm-yarn.md (100%) create mode 100644 docs/content/docs/2.project-templates/1.laravel-basic.md create mode 100644 docs/content/docs/2.project-templates/2.nuxt.md create mode 100644 docs/content/docs/2.project-templates/3.create-your-own-template.md rename docs/content/docs/{1.getting-started => 3.getting-started}/1.how-spin-works.md (89%) rename docs/content/docs/{3.guide => 3.getting-started}/2.add-spin-to-an-existing-project.md (50%) create mode 100644 docs/content/docs/3.getting-started/3.create-a-new-project-with-spin.md rename docs/content/docs/{3.guide => 3.getting-started}/3.preparing-your-servers-for-spin.md (54%) create mode 100644 docs/content/docs/3.getting-started/4.run-a-simple-deployment.md delete mode 100644 docs/content/docs/3.guide/1.create-a-new-laravel-project.md delete mode 100644 docs/content/docs/3.guide/4.zero-downtime-deployments-with-github-actions.md delete mode 100644 docs/content/docs/3.guide/7.using-mkpasswd-to-generate-user-passwords.md create mode 100644 docs/content/docs/4.advanced/1.zero-downtime-deployments-with-github-actions.md rename docs/content/docs/{3.guide/6.generating-a-secure-deployment-key.md => 4.advanced/2.generating-a-secure-deployment-key.md} (100%) rename docs/content/docs/{3.guide/5.adding-common-services.md => 4.advanced/3.adding-other-services.md} (93%) create mode 100644 docs/content/docs/4.command-reference/deploy.md create mode 100644 docs/content/docs/4.command-reference/mkpasswd.md create mode 100644 docs/content/docs/4.command-reference/ps.md create mode 100644 docs/public/images/docs/community-templates/spin-new-community-template.png create mode 100644 docs/public/images/docs/community-templates/spin-official-laravel-template.png create mode 100644 docs/public/images/docs/getting-started/server-dns.png create mode 100755 lib/actions/deploy.sh create mode 100755 lib/actions/mkpasswd.sh create mode 100755 lib/actions/ps.sh delete mode 100644 templates/common/.dockerignore.lineinfile delete mode 100644 templates/common/.gitignore.lineinfile delete mode 100644 templates/common/.infrastructure/conf/spin/collections/.gitignore delete mode 100644 templates/common/.infrastructure/volume_data/.gitignore delete mode 100644 templates/laravel/.github/workflows/README.md delete mode 100644 templates/laravel/.github/workflows/action_deploy-production.yml delete mode 100644 templates/laravel/.github/workflows/service_docker-build-and-publish.yml delete mode 100644 templates/laravel/.infrastructure/conf/traefik/dev/certificates/local-dev-key.pem delete mode 100644 templates/laravel/.infrastructure/conf/traefik/dev/certificates/local-dev.pem delete mode 100644 templates/laravel/.infrastructure/conf/traefik/dev/traefik-certs.yml delete mode 100644 templates/laravel/.infrastructure/conf/traefik/dev/traefik.yml delete mode 100644 templates/laravel/.infrastructure/conf/traefik/prod/traefik.yml delete mode 100644 templates/laravel/Dockerfile delete mode 100644 templates/laravel/docker-compose.ci.yml delete mode 100644 templates/laravel/docker-compose.dev.yml delete mode 100644 templates/laravel/docker-compose.prod.yml delete mode 100644 templates/laravel/docker-compose.yml diff --git a/.github/workflows/action_marketing-site-preview.yml b/.github/workflows/action_marketing-site-preview.yml deleted file mode 100644 index 5dca4854..00000000 --- a/.github/workflows/action_marketing-site-preview.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: Site Deployment - Preview πŸ‘¨β€πŸ”¬ - -on: - pull_request: - types: [opened, synchronize, reopened] - paths: - - docs/** - -jobs: - publish-preview-site: - uses: ./.github/workflows/service_deploy-static-site.yml - secrets: inherit - with: - environment-name: 'ssu-spin (Preview)' \ No newline at end of file diff --git a/.github/workflows/action_marketing-site-publish.yml b/.github/workflows/action_marketing-site-publish.yml deleted file mode 100644 index 22781d24..00000000 --- a/.github/workflows/action_marketing-site-publish.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: Site Deployment - Production πŸš€ -on: - push: - branches: - - main - paths: - - docs/** - -jobs: - publish-production-site: - secrets: inherit - uses: ./.github/workflows/service_deploy-static-site.yml - with: - environment-name: 'ssu-spin (Production)' \ No newline at end of file diff --git a/.github/workflows/service_deploy-static-site.yml b/.github/workflows/service_deploy-static-site.yml deleted file mode 100644 index 2b183d06..00000000 --- a/.github/workflows/service_deploy-static-site.yml +++ /dev/null @@ -1,48 +0,0 @@ -on: - workflow_call: - inputs: - environment-name: - required: true - type: string - -jobs: - deploy-static-site: - runs-on: ubuntu-22.04 - permissions: - contents: read - deployments: write - environment: - name: ${{ inputs.environment-name }} - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-node@v4 - with: - node-version-file: './docs/.nvmrc' - - - name: Set env file - run: | - if [[ -z "$BASE_64_SECRET" ]]; then - echo '🚨🚨🚨 ENV File not set 🚨🚨🚨' 1>&2 - exit 1 - fi - echo $BASE_64_SECRET | base64 -d > .env - working-directory: ./docs - env: - BASE_64_SECRET: ${{ secrets.ENV_FILE_BASE64 }} - - - run: | - yarn install --frozen-lockfile - yarn build - npx nuxi generate - working-directory: ./docs - - - name: Publish to Cloudflare Pages - uses: cloudflare/pages-action@v1 - with: - apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} - accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - projectName: ssu-spin - directory: docs/.output/public - branch: ${{ github.head_ref || github.ref_name }} - gitHubToken: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/README.md b/README.md index 848863a4..9aeecd44 100644 --- a/README.md +++ b/README.md @@ -71,11 +71,6 @@ Spin serves as a collection of open source technologies, put together in one sim - [serversideup/php](https://serversideup.net/open-source/docker-php/) - PHP Docker images highly optimized to work with Laravel + Spin. - [serversideup/docker-ssh](https://github.com/serversideup/docker-ssh) - A lightweight docker image that runs SSH. This is a fantastic method on using a secure SSH tunnel into your database cluster. -## Demo -Here's a demo showing a process of creating a new Laravel project and deploying it to production: - - - ## Resources - **[Website](https://serversideup.net/open-source/spin/)** overview of the product. - **[Docs](https://serversideup.net/open-source/spin/docs)** for a deep-dive on how to use the product. diff --git a/bin/spin b/bin/spin index 16b29130..c35845c5 100755 --- a/bin/spin +++ b/bin/spin @@ -8,16 +8,16 @@ SPIN_ENV=${SPIN_ENV:-dev} export COMPOSE_CMD=${COMPOSE_CMD:-"docker compose"} # Export the current user and group ID -export SPIN_USER_ID=$(id -u) -export SPIN_GROUP_ID=$(id -g) +SPIN_USER_ID=${SPIN_USER_ID:-$(id -u)} +SPIN_GROUP_ID=${SPIN_GROUP_ID:-$(id -g)} +export SPIN_USER_ID +export SPIN_GROUP_ID # Default Images -SPIN_PHP_IMAGE=${SPIN_PHP_IMAGE:-"serversideup/php:beta-cli"} +SPIN_PHP_IMAGE=${SPIN_PHP_IMAGE:-"serversideup/php:cli"} SPIN_NODE_IMAGE=${SPIN_NODE_IMAGE:-"node:20"} -SPIN_ANSIBLE_IMAGE=${SPIN_ANSIBLE_IMAGE:-"willhallonline/ansible:2.15-alpine-3.18"} - -# Default Service Names -SPIN_DEFAULT_PHP_SERVICE_NAME=${SPIN_DEFAULT_PHP_RUN_SERVICE:-"php"} +SPIN_ANSIBLE_IMAGE=${SPIN_ANSIBLE_IMAGE:-"willhallonline/ansible:2.16-alpine-3.19"} +SPIN_ANSIBLE_COLLECTION_NAME=${SPIN_ANSIBLE_COLLECTION_NAME:-"serversideup.spin"} # Script Configuration SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" @@ -32,7 +32,7 @@ source "$SPIN_HOME/lib/functions.sh" setup_color # Check for upgrades, except for development installs and on `spin update` -if [[ $(detect_installation_type) != "development" && "$1" != "update" ]]; then +if [[ "$(installation_type)" != "development" && "$1" != "update" ]]; then check_for_upgrade fi @@ -44,7 +44,7 @@ case "$1" in "" | base64 | debug | help | update | version | --version | -v) : # Silent output for the user, but we're skipping the compose check too. ;; - init | kill | new | prune | provision | vault) + init | kill | mkpasswd | new | prune | provision | vault) check_if_docker_is_running ;; *) @@ -71,6 +71,10 @@ if [ $# -gt 0 ]; then source "$SPIN_HOME/lib/actions/debug.sh" action_debug "$@" ;; + deploy) + source "$SPIN_HOME/lib/actions/deploy.sh" + action_deploy "$@" + ;; down) source "$SPIN_HOME/lib/actions/down.sh" action_down "$@" @@ -99,8 +103,13 @@ if [ $# -gt 0 ]; then source "$SPIN_HOME/lib/actions/logs.sh" action_logs "$@" ;; + mkpasswd) + source "$SPIN_HOME/lib/actions/mkpasswd.sh" + action_mkpasswd "$@" + ;; new) source "$SPIN_HOME/lib/actions/new.sh" + source "$SPIN_HOME/lib/actions/init.sh" action_new "$@" ;; provision) @@ -111,6 +120,10 @@ if [ $# -gt 0 ]; then source "$SPIN_HOME/lib/actions/prune.sh" action_prune "$@" ;; + ps) + source "$SPIN_HOME/lib/actions/ps.sh" + action_ps + ;; pull) source "$SPIN_HOME/lib/actions/pull.sh" action_pull "$@" @@ -140,7 +153,7 @@ if [ $# -gt 0 ]; then action_version ;; *) - echo "\"$1\" is not a valid command. Below are the commands available." + echo "\"$spin_action\" is not a valid command. Below are the commands available." source "$SPIN_HOME/lib/actions/help.sh" action_help ;; diff --git a/docs/components/content/Column.vue b/docs/components/content/Column.vue index 88a81c6f..780c01e4 100644 --- a/docs/components/content/Column.vue +++ b/docs/components/content/Column.vue @@ -10,7 +10,7 @@ \ No newline at end of file diff --git a/docs/components/content/FeatureGrid.vue b/docs/components/content/FeatureGrid.vue index 4cc7ab87..d21fb0ff 100644 --- a/docs/components/content/FeatureGrid.vue +++ b/docs/components/content/FeatureGrid.vue @@ -93,7 +93,7 @@ GitHub Action Support - Spin provides templates to automate the delivery of your application through CI/CD. + We provide open source GitHub Actions to help you ship automatically and easily.
diff --git a/docs/components/content/MarketingGrid.vue b/docs/components/content/MarketingGrid.vue index f79ae217..63069419 100644 --- a/docs/components/content/MarketingGrid.vue +++ b/docs/components/content/MarketingGrid.vue @@ -97,7 +97,7 @@ GitHub Action Support - Spin provides templates to automate the delivery of your application through CI/CD. + We provide open source GitHub Actions to help you ship automatically and easily.
diff --git a/docs/components/content/MarketingHero.vue b/docs/components/content/MarketingHero.vue index 75695da7..138f493e 100644 --- a/docs/components/content/MarketingHero.vue +++ b/docs/components/content/MarketingHero.vue @@ -1,7 +1,7 @@