0

I am looking to deploy my Angular app to Google Cloud, including the following:

  • serving static files produced by ng build
  • on my custom domain: site.example.com
  • proper Angular deep linking (see also Angular docs): serve index.html on site.example.com, site.example.com/home, site.example.com/profile etc, while also serving other files (e. g. /assets/icon.png) normally
  • minimizing costs, as I'm on a very strict budget (<$5/month preferred)

I've tried to deploy my static files to a Google Cloud Storage bucket, and could serve index.html by setting the "website configuraton" -> "index (main) page suffix". However, I do not see a way of redirecting other routes like site.example.com/home to index.html too using only Cloud Storage.

Other things I've looked into include:

  • using a Cloud Load Balancer (as suggested in this article), but I believe it will get very pricey because it uses Compute Engine (right?)
  • using a custom server on Cloud Run or Computer Engine, but this seems like overkill for serving static files, and could be cost intensive
  • using Google App Engine, but I am not sure whether it supports all my requirements (especially the URL rewrites for Angular), and it would be nice to be able to deploy my static files separate from my backend, however I do see this as a fallback alternative and would appreciate any guidance on how to use GAE for this

TL;DR I need help with server-side URL rewrites for Angular and minimizing costs.

Thanks a lot for any help!

JupiterPi
  • 3
  • 1
  • 2
  • I'm not sure to catch your "server side URL rewrite". I'm not expert in Angular, but for me, it's only static files, there is nothing processed server side. Are you sure of what you need? – guillaume blaquiere Apr 29 '23 at 11:38
  • @guillaumeblaquiere It is only static files, but all routes that belong to the app (like site.example.com for the root, but also site.example.com/home, /profile, /viewSomething etc.) should all respond with the index.html static file (and not other static files like home.html, which do not exist). The Angular docs calls it a "deep link in the application", so that unknown routes should "fall back" to index.html). – JupiterPi Apr 29 '23 at 11:46

1 Answers1

0

As long as it's static file, I strongly recommend to use App Engine standard. You serve for free your website (no server cost, static files are served for free) and you have up to 1Gb egress free per day!

In addition, you can use custom domain to plug your DNS name on top of App Engine and let Google Cloud managing the SSL certificate.

Definitively, it's the simplest and the cheapest solution to host static websites.

guillaume blaquiere
  • 66,369
  • 2
  • 47
  • 76