Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: azure deployment #217

Merged
merged 45 commits into from
Dec 8, 2024

Conversation

gentlementlegen
Copy link
Member

@gentlementlegen gentlementlegen commented Dec 2, 2024

Relates to #195
Resolves ubiquity/.github#111

List of changes

This introduces a pipeline and setup to deploy the Kernel on Azure. The testing endpoint is at https://ubiquity-os.azurewebsites.net/
This can be a good backup if we see that Cloudflare fails again (it is back to stable at this time somehow). The two deployments and instances can coexist, and Azure is pay as you go so if we don't use it it doesn't matter much.

New features

  • deploy to Azure
  • deploy the stored secrets in Action Env to Azure Env
  • local setup and scripts

What should be done

  • have working logs (nothing shows in the console)
  • have dev / prod setup (and eventually branches)
  • have an account for Ubiquity Org
  • properly override env variables if set via the script

QA

Meniole/text-conversation-rewards#31 (comment)

.cspell.json Show resolved Hide resolved
@@ -0,0 +1,3 @@
import { app } from "../kernel";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { app } from "../kernel";
export { app } from "../kernel";

Can't you just do that

tsup.config.ts Outdated Show resolved Hide resolved
@rndquu rndquu mentioned this pull request Dec 3, 2024
@gentlementlegen gentlementlegen marked this pull request as ready for review December 4, 2024 07:17
@gentlementlegen gentlementlegen changed the title Feat/azure feat: azure deployment Dec 4, 2024
@gentlementlegen
Copy link
Member Author

@whilefoo rfc

@0x4007
Copy link
Member

0x4007 commented Dec 4, 2024

The two deployments and instances can coexist

This would be really interesting if we had load balancing, although implementation would be tricky if we have to manually check for output from every plugin before posting a new comment or taking an action.

I assume you mean we would have both deployments live but we would have to manually switch which responds to events from the GitHub App?

@gentlementlegen
Copy link
Member Author

Yes we should change the webhook url within the GitHub App so it targets one or the other.


deploy:
runs-on: windows-latest
needs: build
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be run after update-environment? I was recently using Azure App Service and when I changed env I had to restart the app

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think both steps restart the app, so it doesn't matter much. The best way would be to combine the two steps, the command line can handle upload + local.storage.settings upload but the GitHub Action does not support it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub Action does not support it.

That seems unlikely because its a fully capable ubuntu box.

.github/workflows/azure-deploy.yml Outdated Show resolved Hide resolved
@rndquu rndquu requested review from rndquu and removed request for rndquu December 4, 2024 15:47
@rndquu
Copy link
Member

rndquu commented Dec 4, 2024

@gentlementlegen On bun install && bun dev getting this output:

✘ [ERROR] Build failed with 3 errors:

  ✘ [ERROR] Could not resolve "openai"
  
      src/kernel.ts:8:19:
        8 │ import OpenAI from "openai";
          ╵                    ~~~~~~~~
  
    The Yarn Plug'n'Play manifest forbids importing "openai" here because it's not listed as a
  dependency of this package:
  
      .pnp.cjs:4514:31:
        4514 │         "packageDependencies": [\
             ╵                                ~~
  
    You can mark the path "openai" as external to exclude it from the bundle, which will remove this
  error.
  
  
  ✘ [ERROR] Could not resolve "hono"
  
      src/kernel.ts:9:43:
        9 │ import { Context, Hono, HonoRequest } from "hono";
          ╵                                            ~~~~~~
  
    The Yarn Plug'n'Play manifest forbids importing "hono" here because it's not listed as a
  dependency of this package:
  
      .pnp.cjs:4514:31:
        4514 │         "packageDependencies": [\
             ╵                                ~~
  
    You can mark the path "hono" as external to exclude it from the bundle, which will remove this
  error.
  
  
  ✘ [ERROR] Could not resolve "hono/adapter"
  
      src/kernel.ts:10:46:
        10 │ import { env as honoEnv, getRuntimeKey } from "hono/adapter";
           ╵                                               ~~~~~~~~~~~~~~
  
    The Yarn Plug'n'Play manifest forbids importing "hono" here because it's not listed as a
  dependency of this package:
  
      .pnp.cjs:4514:31:
        4514 │         "packageDependencies": [\
             ╵                                ~~
  
    You can mark the path "hono/adapter" as external to exclude it from the bundle, which will
  remove this error.

Do you get the same errors?

@0x4007
Copy link
Member

0x4007 commented Dec 4, 2024

Anything yarn related should 1. be removed from the project and 2. if there are still problems then it must be your environment. Everything should be using bun here.

tsconfig.json Show resolved Hide resolved
@gentlementlegen
Copy link
Member Author

@gentlementlegen On bun install && bun dev getting this output:

✘ [ERROR] Build failed with 3 errors:

  ✘ [ERROR] Could not resolve "openai"
  
      src/kernel.ts:8:19:
        8 │ import OpenAI from "openai";
          ╵                    ~~~~~~~~
  
    The Yarn Plug'n'Play manifest forbids importing "openai" here because it's not listed as a
  dependency of this package:
  
      .pnp.cjs:4514:31:
        4514 │         "packageDependencies": [\
             ╵                                ~~
  
    You can mark the path "openai" as external to exclude it from the bundle, which will remove this
  error.
  
  
  ✘ [ERROR] Could not resolve "hono"
  
      src/kernel.ts:9:43:
        9 │ import { Context, Hono, HonoRequest } from "hono";
          ╵                                            ~~~~~~
  
    The Yarn Plug'n'Play manifest forbids importing "hono" here because it's not listed as a
  dependency of this package:
  
      .pnp.cjs:4514:31:
        4514 │         "packageDependencies": [\
             ╵                                ~~
  
    You can mark the path "hono" as external to exclude it from the bundle, which will remove this
  error.
  
  
  ✘ [ERROR] Could not resolve "hono/adapter"
  
      src/kernel.ts:10:46:
        10 │ import { env as honoEnv, getRuntimeKey } from "hono/adapter";
           ╵                                               ~~~~~~~~~~~~~~
  
    The Yarn Plug'n'Play manifest forbids importing "hono" here because it's not listed as a
  dependency of this package:
  
      .pnp.cjs:4514:31:
        4514 │         "packageDependencies": [\
             ╵                                ~~
  
    You can mark the path "hono/adapter" as external to exclude it from the bundle, which will
  remove this error.

Do you get the same errors?

I tested deleting all the node modules and the lockb, bun dev and bun start:azure are working fine. What version of bun are you using?

@rndquu
Copy link
Member

rndquu commented Dec 5, 2024

I tested deleting all the node modules and the lockb, bun dev and bun start:azure are working fine. What version of bun are you using?

This was smth my local env related, after removing the node_modules it all started working

@gentlementlegen
Copy link
Member Author

Glad it works. Once merge, I will have to set all the secrets for deployment in the repo as well.

tsup.config.ts Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you use tsx

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tsx only runs code, it cannot build, as far as I know.

package.json Outdated
@@ -32,7 +32,13 @@
"jest:test": "jest --coverage",
"plugin:hello-world": "tsx tests/__mocks__/hello-world-plugin.ts",
"setup-kv": "bun --env-file=.dev.vars scripts/setup-kv-namespace.ts",
"setup": "tsx ./scripts/setup.ts"
"setup": "tsx ./scripts/setup.ts",
"start:azure": "run-p proxy build:watch start",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the formatting correct or is it a render bug in my GitHub iOS client

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the space is a tab most likely, I will fix that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think run-s might make more sense, to run in series instead of parallel? I suggest that because build generally should complete before starting.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's true but since we are watching the code to rebuild on save, I think it makes more sense to run in parallel otherwise saving won't reload the code.

.funcignore Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this file

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we releasing packages for Azure?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's what Azure will pack to serve on the endpoint, files listed here won't be included in the build.

@gentlementlegen gentlementlegen merged commit bb72c0a into ubiquity-os:development Dec 8, 2024
3 checks passed
@gentlementlegen gentlementlegen deleted the feat/azure branch December 8, 2024 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cloudflare as a Risk
4 participants