diff --git a/.github/workflows/uffizzi-preview.yaml b/.github/workflows/uffizzi-preview.yaml index e15a23f4..d846a434 100644 --- a/.github/workflows/uffizzi-preview.yaml +++ b/.github/workflows/uffizzi-preview.yaml @@ -1,12 +1,6 @@ -name: Build Images and Handle Uffizzi Previews. +name: Build Images and Deploy Preview Environment on: - push: - branches: - - main - - master - - staging - - qa pull_request: types: [opened,reopened,synchronize,closed] @@ -22,15 +16,16 @@ jobs: uses: actions/checkout@v3 - name: Generate UUID image name id: uuid - run: echo "::set-output name=uuid::$(uuidgen)" + run: echo "UUID_VOTE=$(uuidgen)" >> $GITHUB_ENV - name: Docker metadata id: meta - uses: docker/metadata-action@v3 + uses: docker/metadata-action@v4 with: - images: ttl.sh/${{ steps.uuid.outputs.uuid }} + # An anonymous, emphemeral registry built on ttl.sh + images: registry.uffizzi.com/${{ env.UUID_VOTE }} tags: type=raw,value=24h - - name: Build and Push Image to ttl.sh ephemeral registry - uses: docker/build-push-action@v2 + - name: Build and Push Image to Uffizzi Ephemeral Registry + uses: docker/build-push-action@v3 with: push: true tags: ${{ steps.meta.outputs.tags }} @@ -48,21 +43,22 @@ jobs: uses: actions/checkout@v3 - name: Generate UUID image name id: uuid - run: echo "::set-output name=uuid::$(uuidgen)" + run: echo "UUID_WORKER=$(uuidgen)" >> $GITHUB_ENV - name: Docker metadata id: meta - uses: docker/metadata-action@v3 + uses: docker/metadata-action@v4 with: - images: ttl.sh/${{ steps.uuid.outputs.uuid }} + # An anonymous, emphemeral registry built on ttl.sh + images: registry.uffizzi.com/${{ env.UUID_WORKER }} tags: type=raw,value=24h - - name: Build and Push Image to ttl.sh Ephemeral Registry - uses: docker/build-push-action@v2 + - name: Build and Push Image to Uffizzi Ephemeral Registry + uses: docker/build-push-action@v3 with: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} context: ./worker - + build-result: name: Build and Push `result` runs-on: ubuntu-latest @@ -74,21 +70,22 @@ jobs: uses: actions/checkout@v3 - name: Generate UUID image name id: uuid - run: echo "::set-output name=uuid::$(uuidgen)" + run: echo "UUID_RESULT=$(uuidgen)" >> $GITHUB_ENV - name: Docker metadata id: meta - uses: docker/metadata-action@v3 + uses: docker/metadata-action@v4 with: - images: ttl.sh/${{ steps.uuid.outputs.uuid }} + # An anonymous, emphemeral registry built on ttl.sh + images: registry.uffizzi.com/${{ env.UUID_RESULT }} tags: type=raw,value=24h - - name: Build and Push Image to ttl.sh Ephemeral Registry - uses: docker/build-push-action@v2 + - name: Build and Push Image to Uffizzi Ephemeral Registry + uses: docker/build-push-action@v3 with: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} context: ./result - + build-loadbalancer: name: Build and Push `loadbalancer` runs-on: ubuntu-latest @@ -100,32 +97,33 @@ jobs: uses: actions/checkout@v3 - name: Generate UUID image name id: uuid - run: echo "::set-output name=uuid::$(uuidgen)" + run: echo "UUID_LOADBALANCER=$(uuidgen)" >> $GITHUB_ENV - name: Docker metadata id: meta - uses: docker/metadata-action@v3 + uses: docker/metadata-action@v4 with: - images: ttl.sh/${{ steps.uuid.outputs.uuid }} + # An anonymous, emphemeral registry built on ttl.sh + images: registry.uffizzi.com/${{ env.UUID_LOADBALANCER }} tags: type=raw,value=24h - - name: Build and Push Image to ttl.sh Ephemeral Registry - uses: docker/build-push-action@v2 + - name: Build and Push Image to Uffizzi Ephemeral Registry + uses: docker/build-push-action@v3 with: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} context: ./loadbalancer - + render-compose-file: name: Render Docker Compose File runs-on: ubuntu-latest - if: ${{ github.event_name != 'pull_request' || github.event.action != 'closed' }} - needs: + needs: - build-vote - build-worker - build-result - build-loadbalancer outputs: - compose-file-cache-key: ${{ steps.hash.outputs.hash }} + compose-file-cache-key: ${{ env.COMPOSE_FILE_HASH }} + compose-file-cache-path: docker-compose.rendered.yml steps: - name: Checkout git repo uses: actions/checkout@v3 @@ -148,28 +146,26 @@ jobs: cat docker-compose.rendered.yml - name: Hash Rendered Compose File id: hash - run: echo "::set-output name=hash::$(md5sum docker-compose.rendered.yml | awk '{ print $1 }')" + run: echo "COMPOSE_FILE_HASH=$(md5sum docker-compose.rendered.yml | awk '{ print $1 }')" >> $GITHUB_ENV - name: Cache Rendered Compose File uses: actions/cache@v3 with: path: docker-compose.rendered.yml - key: ${{ steps.hash.outputs.hash }} + key: ${{ env.COMPOSE_FILE_HASH }} deploy-uffizzi-preview: name: Use Remote Workflow to Preview on Uffizzi - needs: - - render-compose-file + needs: render-compose-file uses: UffizziCloud/preview-action/.github/workflows/reusable.yaml@v2 - if: ${{ github.event_name == 'pull_request' && github.event.action != 'closed' }} with: compose-file-cache-key: ${{ needs.render-compose-file.outputs.compose-file-cache-key }} - compose-file-cache-path: docker-compose.rendered.yml - server: https://app.uffizzi.com/ + compose-file-cache-path: ${{ needs.render-compose-file.outputs.compose-file-cache-path }} + server: https://pr-711-deployment-10631-uffizzi-platform.app.uffizzi.com permissions: contents: read pull-requests: write id-token: write - + delete-uffizzi-preview: name: Use Remote Workflow to Delete an Existing Preview uses: UffizziCloud/preview-action/.github/workflows/reusable.yaml@v2 @@ -177,7 +173,7 @@ jobs: with: compose-file-cache-key: '' compose-file-cache-path: docker-compose.rendered.yml - server: https://app.uffizzi.com/ + server: https://pr-711-deployment-10631-uffizzi-platform.app.uffizzi.com permissions: contents: read pull-requests: write diff --git a/README.md b/README.md index f6d6408e..8c53f837 100644 --- a/README.md +++ b/README.md @@ -1,69 +1,73 @@ # Uffizzi Quickstart (~ 1 minute) -Get started using Uffizzi Preview Environments in 3 simple steps... +Go from pull request to Uffizzi Preview Environment in less than one minute... -### 1. Fork this repo +### 1. Fork this repo -Be sure to uncheck the option **Copy the `main` branch only**. This ensures that the `try-uffizzi` branch will be included in your fork. +⚠️ Be sure to **uncheck** the option **Copy the `main` branch only**. - +This ensures that the `try-uffizzi` branch will be included in your fork. +  + ### 2. Enable GitHub Actions workflows for your fork -Select **Actions**, then select **I understand my workflows, go ahead and enable them**. GitHub Actions is free in public repositories. +Select **Actions**, then select **I understand my workflows, go ahead and enable them**. - + -### 3. Open a pull request for `try-uffizzi` branch against `main` in your fork +### 3. Open a pull request for `try-uffizzi` branch against `main` in your fork -Be sure that you're opening a PR on the branches of _your fork_ (i.e. `your-account/main` ← `your-account/try-uffizzi`). If you try to open a PR for `UffizziCloud/main` ← `your-account/try-uffizzi`, the Actions workflow will not run in this example. +⚠️ Be sure that you're opening a PR on the branches of _your fork_ (i.e. `your-account/main` ← `your-account/try-uffizzi`). -That's it! This will kick off a GitHub Actions workflow and post the Preview Environment URL as a comment to your PR issue. +If you try to open a PR for `UffizziCloud/main` ← `your-account/try-uffizzi`, the Actions workflow will not run in this example. + +That's it! This will kick off a GitHub Actions workflow and post the Preview Environment URL as a comment to your PR issue. uffizzi-bot -## What to expect +## What to expect -The PR will trigger a [GitHub Actions workflow](https://github.com/UffizziCloud/quickstart/blob/main/.github/workflows/uffizzi-preview.yaml) that creates a Uffizzi Preview Environment for the [microservices application](#architecture-of-this-example-app) defined by this repo. The Preview Environment URL will be posted as a comment in your PR issue when the workflow completes, along with a link to the Uffizzi Dashboard where you can view application logs. The Preview Environment will be deleted when the PR is merged/closed or after 1 hour ([configurable](https://github.com/UffizziCloud/quickstart/blob/6aba97b1e27c8fafba2d6461087abfe06becf9ce/docker-compose.uffizzi.yml#L7)). +The PR will trigger a [GitHub Actions workflow](.github/workflows/uffizzi-preview.yaml) that creates a Uffizzi Preview Environment for the [microservices application](#architecture-of-this-example-app) defined by this repo. The Preview Environment URL will be posted as a comment in your PR issue when the workflow completes, along with a link to the Uffizzi Dashboard where you can view application logs. The Preview Environment will be deleted when the PR is merged/closed or after 1 hour ([configurable](https://github.com/UffizziCloud/quickstart/blob/6cbbb0f65e899cb05c96ea42531280f8d959df1d/docker-compose.uffizzi.yml#L7)). -## How it works +## How it works -#### Configuration +### Configuration -Previews are configured with a [Docker Compose template](https://github.com/UffizziCloud/quickstart/blob/main/docker-compose.uffizzi.yml) that describes the application components and a [GitHub Actions workflow](https://github.com/UffizziCloud/quickstart/blob/main/.github/workflows/uffizzi-preview.yaml) that includes a series of jobs triggered by a `pull_request` event and subsequent `push` events: +Preview Environments are configured with a [Docker Compose template](docker-compose.uffizzi.yml) that describes the application components and a [GitHub Actions workflow](.github/workflows/uffizzi-preview.yaml) that includes a series of jobs triggered by a `pull_request` event and subsequent `push` events: -1. [Build and push images to a container registry](https://github.com/UffizziCloud/quickstart/blob/5699f461f752b0bd787d69abc2cfad3b79e0308b/.github/workflows/uffizzi-preview.yaml#L14-L116) -2. [Render a Docker Compose file](https://github.com/UffizziCloud/quickstart/blob/5699f461f752b0bd787d69abc2cfad3b79e0308b/.github/workflows/uffizzi-preview.yaml#L118-L156) from the Docker Compose template and the built images -3. [Deploy the application (per the Docker Compose file) to a Uffizzi Preview Environment](https://github.com/UffizziCloud/quickstart/blob/5699f461f752b0bd787d69abc2cfad3b79e0308b/.github/workflows/uffizzi-preview.yaml#L158-L171) and post a comment to the PR issue -4. [Delete the Preview Environment](https://github.com/UffizziCloud/quickstart/blob/5699f461f752b0bd787d69abc2cfad3b79e0308b/.github/workflows/uffizzi-preview.yaml#L173-L184) when the PR is merged/closed or after `1h` +1. [Build and push images to a container registry](https://github.com/UffizziCloud/quickstart/blob/6cbbb0f65e899cb05c96ea42531280f8d959df1d/.github/workflows/uffizzi-preview.yaml#L8-L114) +2. [Render a Docker Compose file](https://github.com/UffizziCloud/quickstart/blob/6cbbb0f65e899cb05c96ea42531280f8d959df1d/.github/workflows/uffizzi-preview.yaml#L116-L154) from the Docker Compose template and the built images +3. [Deploy the application to a Uffizzi Preview Environment](https://github.com/UffizziCloud/quickstart/blob/6cbbb0f65e899cb05c96ea42531280f8d959df1d/.github/workflows/uffizzi-preview.yaml#L156-L167) and post a comment to the PR issue +4. [Delete the Preview Environment](https://github.com/UffizziCloud/quickstart/blob/6cbbb0f65e899cb05c96ea42531280f8d959df1d/.github/workflows/uffizzi-preview.yaml#L169-L180) when the PR is merged/closed or after [`1h`](https://github.com/UffizziCloud/quickstart/blob/6cbbb0f65e899cb05c96ea42531280f8d959df1d/docker-compose.uffizzi.yml#L7) -#### Uffizzi Cloud +### Uffizzi Cloud Running this workflow will create a [Uffizzi Cloud](https://uffizzi.com) account and project from your GitHub user and repo information, respectively. If you sign in to the [Uffizzi Dashboard](https://app.uffizzi.com/sign_in) you can view logs, password protect your Preview Environments, manage projects and team members, set role-based access controls, and configure single-sign on (SSO). -Each account receives 10,000 preview minutes per month for free. If you exceed this amount, your Preview Environments will be paused unless you add a credit card. See [our pricing](https://uffizzi.com/pricing) for details. Alternatively, you can [install open-source Uffizzi](https://github.com/UffizziCloud/uffizzi_app/blob/develop/INSTALL.md) if you have your own Kubernetes cluster. +Open-source projects preview for free on Uffizzi Cloud. All other accounts receive 10,000 preview minutes per month for free. If you exceed this amount, your Preview Environments will be paused unless you add a credit card. See [our pricing](https://uffizzi.com/pricing) for details or to request free access as an open-source maintainer. Alternatively, if you don't want to use Uffizzi Cloud, you can [install open-source Uffizzi](https://github.com/UffizziCloud/uffizzi_app/blob/develop/INSTALL.md) on your own Kubernetes cluster. ## Acceptable Use -We strive to keep Uffizzi Cloud free or inexpensive for individuals and small teams. Therefore, activities such as crypto mining, filesharing, bots, and similar uses that lead to increased cost and intermittent issues for other users are strictly prohibited per the [Acceptable Use Policy](https://uffizzi.zendesk.com/hc/en-us/articles/4410657390999-Acceptable-Use-Policy). Violators of this policy are subject to permanent ban. +We strive to keep Uffizzi Cloud free or inexpensive for individuals and small teams. Therefore, activities such as crypto mining, filesharing, bots, and similar uses that lead to increased cost and intermittent issues for other users are strictly prohibited per the [Acceptable Use Policy](https://uffizzi.zendesk.com/hc/en-us/articles/4410657390999-Acceptable-Use-Policy). Violators of this policy are subject to permanent ban. ## Architecture of this Example App -The application defined by this repo allows users to vote for dogs or cats and see the results. It consists of the following microservices: +The application defined by this repo allows users to vote for dogs or cats and see the results. It consists of the following microservices: -* **voting-app** - A frontend web app in [Python](/vote) which lets you vote between two options -* **redis** - A [Redis](https://hub.docker.com/_/redis/) queue which collects new votes -* **worker** - A [.NET Core](/worker/src/Worker) worker which consumes votes and stores them in… +* **voting-app** - A frontend web app in [Python](/vote) which lets you vote between two options +* **redis** - A [Redis](https://hub.docker.com/_/redis/) queue which collects new votes +* **worker** - A [.NET Core](/worker/src/Worker) worker which consumes votes and stores them in… * **db** - A [PostgreSQL](https://hub.docker.com/_/postgres/) database backed by a Docker volume * **result-app** - A [Node.js](/result) web app which shows the results of the voting in real time ## Set up Preview Environments for your application -You can follow this [step-by-step guide](https://docs.uffizzi.com/set-up-uffizzi-for-your-application) to configure Preview Environments for your own application. The required components are: +You can follow this [step-by-step guide](https://docs.uffizzi.com/set-up-uffizzi-for-your-application) to configure Preview Environments for your own application. The required components are: -- **A Docker Compose template (`docker-compose.uffizzi.yml`) committed to your repo** - This template must include [`ingress`](https://github.com/UffizziCloud/quickstart/blob/6aba97b1e27c8fafba2d6461087abfe06becf9ce/docker-compose.uffizzi.yml#L2-L5) and `services` definitions. For a full list of supported keywords, see [Docker Compose for Uffizzi](https://docs.uffizzi.com/references/compose-spec/). +- **A Docker Compose template (`docker-compose.uffizzi.yml`) committed to your repo** - This template must include [`ingress`](https://github.com/UffizziCloud/quickstart/blob/6aba97b1e27c8fafba2d6461087abfe06becf9ce/docker-compose.uffizzi.yml#L2-L5) and `services` definitions. For a full list of supported keywords, see [Docker Compose for Uffizzi](https://docs.uffizzi.com/references/compose-spec/). - **A Uffizzi preview job added to your pipeline** - In the example app used by this quickstart guide, we use GitHub and GitHub Actions, but Uffizzi is designed to work with any version control system or CI platform. As a convenience, we've written actions/jobs for [these popular CI platforms](https://github.com/UffizziCloud/uffizzi_app/tree/develop/ci/). If your platform is not listed, you can still add Uffizzi to your pipeline by wrapping the [Uffizzi CLI](https://github.com/UffizziCloud/uffizzi_cli), which is distributed as a container image [available on Docker Hub](https://hub.docker.com/r/uffizzi/cli). See our GitHub [`preview-action`](https://github.com/UffizziCloud/preview-action/blob/master/action.yaml) and [reusable workflow](https://github.com/UffizziCloud/preview-action/blob/master/.github/workflows/reusable.yaml) as examples. @@ -95,9 +99,9 @@ Uffizzi does not replace GitHub Actions or any other CI provider. Uffizzi previe
Can I connect Uffizzi with Netlify/Vercel? -Yes. While Uffizzi supports full-stack previews, some users who already leverage frontend platforms like Netlify or Vercel want to add Uffizzi previews for their APIs/backend. For help configuring this scenario see: +Yes. While Uffizzi supports full-stack previews, some users who already leverage frontend platforms like Netlify or Vercel want to add Uffizzi previews for their APIs/backend. For help configuring this scenario see:
@@ -109,4 +113,4 @@ Yes. Check out the main re ## Get in touch -For questions, concerns, issues, or feature requests, please join our fast growing [community](https://uffizzi.slack.com/join/shared_invite/zt-ffr4o3x0-J~0yVT6qgFV~wmGm19Ux9A#/shared-invite/email) on Slack. +For questions, concerns, issues, or feature requests, please join our fast growing [community](https://uffizzi.slack.com/join/shared_invite/zt-ffr4o3x0-J~0yVT6qgFV~wmGm19Ux9A#/shared-invite/email) on Slack.