[Rant] Deploying Websites
by Cory on February 29, 2020 6:38 PM (Edited February 29, 2020 6:40 PM)
"I need to put this website on the internet", you plaintively mutter. You browse different cloud services and they assure you that it is quite simple (in 43 easy steps). You get inundated by cryptically named services like Amazon EC2! App Engine! Cloud Functions; serverless lambda functions, Amplify. What should you click?? What does this have to do with deploying websites?
What the heck
You pick the first result off Google for "deploy angular app aws" and start reading the instructions and it's just this soup of words that seem to mean things separately but are strung into a sequence that defies all logic.
Build an app using the Amplify Framework which contains:
* CLI toolchain for creating and managing your serverless backend
*Framework-specific UI component libraries for React, React Native, Angular, Ionic and Vue
What the fuck is a "category based programming model"?? How do I put my stupid website on the internet? Is this what I'm supposed to use to do this?
Whatever. You put aside the question for the moment and keep reading. Let's figure out what the heck this stuff is first. The guide spends paragraphs describing how to setup an Angular app, build it, and view it on your local computer. Ok, weird. You start skimming and skip down until the stuff you're reading once again no longer makes sense. The next section seems promising. Run
amplify init. So apparently this is a wizard that asks you a bunch of questions like, "Do you want to use an AWS profile?" I guess??? So, you enter in
"Y" and open the referenced documentation and go down a rabbit hole. You run into errors along the way and get messages like "profile configuration missing" causing the wizard to exit early, having accomplished nothing. You mess up so you have to start over like 3 times. After going on some detour to set up an AWS profile by clicking through the console to get a new license key pair and then copying a file to your computer, you manage to get the wizard to work.
You search some more and miraculously find a couple comments with people who know what they're doing. Put these 3 lines of angular code in your app to solve "global not defined". It works, thank god. That's one problem out of the way. Now you run the app and you get "could not find file ./aws-export". Great.
You find a github issues page for this error and explaining that this file should be autogenerated by the wizard. You look in your local repository and it's totally there. But when you run the wizard, it can't find the file. The stack overflow people say the solution is to run
amplify push to have it re-generate the file. That doesn't make any sense, but let's try it anyway. You do that and the tool refuses to push because everything is already up to date. Ok. You find some people with similar problems on stack overflow, but the issues have been auto-closed by robots for lack of activity. WHY???
Day 3 of trying to deploy this stupid app.
You decide to give up on this Amplify bullshit because now you're just losing sleep over it. You realized the other day that you should just go the tried and true route of deploying using Amazon EC2 (virtual machine hosting) because at least it doesn't force you into guided setup where nothing works.
The EC2 setup is complicated but at least it's familiar because you're basically SSHing into a linux PC and then installing everything you installed on your own computer. After a single day, you've uploaded a built angular app onto the EC2 instance, run
node backend.js to setup your REST endpoint, and then set up nginx to host both the app and REST api from the external IP address.
Unfortunately, while this was relatively simple, it probably doesn't scale and will fall over as soon as it receives any amount of traffic. The EC2 free tier doesn't even have enough memory to build angular (I had to build angular on my local pc and then
dist/ files to the EC2 instance).
Yeah so here's the app:
I'll figure something permanent out some day. Let's try react now...
This Thought is part of Web Development
General Web Development Thoughts and Odds and Ends