Skip to content

Configure GitHub Actions to build and deploy the app#7

Merged
bigdogwillfeed merged 15 commits into
mainfrom
build-and-deploy
Jan 30, 2023
Merged

Configure GitHub Actions to build and deploy the app#7
bigdogwillfeed merged 15 commits into
mainfrom
build-and-deploy

Conversation

@bigdogwillfeed
Copy link
Copy Markdown
Contributor

@bigdogwillfeed bigdogwillfeed commented Jan 30, 2023

This took a bunch of faffing around, as the Azure method of deploying apps from GitHub is now entirely based on GitHub Actions (so this isn't the same as DevBot or the blog or the public site).

Work not in this PR:

  • configure a windows node 18 app service using the wizard in the Azure portal... nothing too exciting here (make sure websockets are turned on)
  • add cloudflare CNAME
  • configure custom domain and cert binding in Azure (using keyvault cert)
  • add application setting SCM_DO_BUILD_DURING_DEPLOYMENT set to true (this makes npm install --production run after a deployment)

Work in this PR:

  • configure the syncserver to serve the built app instead of just a message that it's running
  • add build and start script
  • workflow file (starting with the one automatically made by Azure when following the App Service setup wizard, fixing it as I tested)
  • change dependencies so dependencies is only what is needed to run in prod and devDependencies is everything else. This makes deployment faster because we install less on the app service
  • add a special run.cjs file to make Azure happy (found at https://stackoverflow.com/a/67111490/1172663)
  • configure PORT to not assume an integer
  • infer sync server location from the current location

The end result is that you can navigate to xdev.devresults.com and see the current app. The sync server is up and running so if you use the same documentID on a different machine or browser, you'll see pretty quick synchronization between the two clients. Pushes to main will automatically deploy the app, and there's also a button to deploy on demand (I think it deploys HEAD, but I haven't checked)

Further work:
-the address of the "always-on" peer is guessed at run-time, but it would be nice if it was a user configuration option

uses `vite` because it seems to work well enough /shrug
The fact that we return anything means the app is running, so may as well serve the built app. That makes deployment easy... just ship the whole thing to one app service
Feel free to replace with something else... it's just nice to get pieces working
This should hopefully make things go (much?) faster. We'll install dependencies on the server when it's time to run
It's installed and it's what we use locally :)
Put all the dependencies for the sync server in dependencies and everything else in devDependencies. This should improve deployment time by reducing what we need to install
Without this, I was getting "Error [ERR_REQUIRE_ESM] ... Instead change the require of syncserver.js in C:\Program Files (x86)\iisnode\interceptor.js to a dynamic import()"
Azure gives us a pipe to listen on, represented as a string path... not a port number.
Not ideal, because now we can't use the local server as our peer. But we don't currently have any tooling for a run-time configuration option here.
Started with an out-of-date template from Azure... let's make sure we can use the latest versions
This gives us a way to use the local syncserver in local development and the production sync server in prod. Longer term, it might be a good idea to have UI to configure this, but it's not critical at the moment
@pull-request-size pull-request-size Bot added size/L and removed size/M labels Jan 30, 2023
Copy link
Copy Markdown
Member

@brentkeller brentkeller left a comment

Choose a reason for hiding this comment

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

This looks really good. Thanks for a nice elegant solution here and for all the frustration you endured to figure out the Azure pitfalls.

@bigdogwillfeed bigdogwillfeed merged commit 85dfa74 into main Jan 30, 2023
@bigdogwillfeed bigdogwillfeed deleted the build-and-deploy branch January 30, 2023 18:35
@bigdogwillfeed bigdogwillfeed mentioned this pull request Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants