gcloud storage mkdocs and index.html don't play nice - gcloud

I am hosting a static site on google cloud storage that is generated by mkdocs. The error that I am experiencing however, shouldn't be related by this library though.
I have my permissions set up and I can view the site over at
https://storage.googleapis.com/<bucketname>/<folder>/index.html
This is fine, but it cannot open this url:
https://storage.googleapis.com/<bucketname>/<folder>/
It doesn't recognise that it should grab the index.html file.
This isn't so much an issue for the index page (I could just point users to that page) but it is a huge issue for all the other links on the site. There's a subfolder that is generated with this structure:
site/planning
├── week1
│   └── index.html
├── week2
│   └── index.html
├── week3
│   └── index.html
└── week4
└── index.html
The google storage docs share some light on what might be going on. But even after applying their recommendation it doesn't work.
> gsutil web set -m index.html gs://<bucketname>/
Setting website configuration on gs://<bucketname>/...
So I'm looking for a solution. My thoughts are:
Maybe GCloud doesn't like the fact that I don't have my own domain name. This should matter but it might not help.
Maybe there's a setting in mkdocs such that not everything is generated via index.html.
Not use GCloud storage for this and instead use github/gitlab pages or something to host this static site.
Any help is much appreciated.

On the GCS part, this behaviour is explained in the docs:
Website configurations are only used to interpret requests directed to
CNAME aliases of c.storage.googleapis.com. (that is, requests where
the hostname is a custom domain). For example, only requests to
www.example.com show the index page.
Thus, API behavior for requests to Cloud Storage domains, such as
storage.googleapis.com/www.example.com, is preserved. For example, you
can continue to list objects in the www.example.com bucket as you
would for any other bucket. In the case of the www.example.com bucket,
the object listing you receive includes 404.html and index.html.
This mainly means that there are no redirects or special behaviors when accessing the objects through the API address, since this would cause the API to be inconsistent.
Definitely, the issue in GCS is that you're not using a custom domain.
On the mkdocs part, it looks like the use_directory_urls:false would do the trick.

Related

Deploying a MERN app to render.com with one main folder structure - not separate front and back

I have a MERN app that I would like to deploy to render.com. I just have 2 quick questions:
Of all the tutorials that I have watched, they all have separate github repos - 1 for the frontend, 1 for the backend. So on render.com, they can simply choose the frontend or the backend repo when they want to deploy. However, my folder structure is not like this - mine is one main github repo, and inside that repo, there is 1 frontend folder and 1 backend folder. How do I go about solving this?
When I give render.com (or heroku, netlify, etc.) access to my github account, is it safe? Does this mean they will be able to read and change stuff in my github account?
Thanks in advance for your help
My repo has the same structure as yours, one frontend folder and one backend folder.
You need to create a new Web Service for your backend folder. When creating a new web service, just set the Root Directory to backend. When you're done with the other fields and deployed your backend, create a Static Site for your frontend. Set the root directory of your static site to frontend. Set Publish Directory to build.
Probably safe but I'm new to the service as well. I believe they are only using that to be able to pull your repositories so that you can select them on Render. And also, of course, for auto or manual deployment.

Github page version number syntax

I have a github repo that is also a github page. I use it as a CDN like so:
https://agentscript.org/src/Model.js
(agentscript.org is a CNAME forwarder to backspaces.github.io/agentscript/)
I would like to access the code by release number. So for example something like:
https://agentscript.org#0.9.0/src/Model.js
Is there a way for me to do this? The above fails. Maybe a different syntax?
Note that npm publishing allows this to work on npm based CDNs like skypack or unpkg:
https://unpkg.com/agentscript#0.9.0/src/Model.js
https://cdn.skypack.dev/agentscript#0.9.0/src/Model.js
GitHub Pages doesn't offer a feature like this. The reason is that GitHub Pages is designed to host a personal website or a site for your open source project, but isn't designed to be a CDN. The documentation outlines that there are limits, so if you need a CDN, you need to host your project on an actual CDN.

Helm Chart Definitions for Multi Cluster Codebase

I have a project that contains the deployment descriptor files for Kubernetes. This project has a folder structure that looks like this:
> project-deployment
> - base
> - dev
> - production
Inside the base folder, I have the kubernetes deployment files (deployment, service, namespaces etc.,). In the dev and production folder, I have kustomization.yaml that composes everything from the base folder. So far so good. I now want to introduce helm into this so that I can manage my releases much better. My question now is how do I go about structuring my folder structure?
Should I move everything (base, dev and production) folder into templates and just have one Charts.yaml and values.yaml? Any thoughts?
The configuration values that you push into your charts should be separate between environments. Build simple extendable charts that can have overrides per environment.
For example, a good workflow would have different value files per environment with specific differences in configuration:
~/myapp
└── config
├── production.yml
└── staging.yml
There are tools that can help you manage that particular use case. For example, consider using orca:
What Orca does best is manage environments. An Environment is a
Kubernetes namespace with a set of Helm charts installed on it. There
are a few use cases you will probably find useful right off the bat.
There are also some examples provided with it.
I also recommend going through the official The Chart Best Practices Guide.

Link custom domain to any GitHub repo

I am aware that on GitHub you can create a repository, <username>.github.io, which will be a personal website. I also understand you can link custom domains to this, so example.com would show the website in your GitHub repo.
I have a couple questions though.
At the moment, I have a GitHub project - let's call it FooProject. I have purchased a custom domain name for a website to showcase the project. How can I create a website for this, hosted on GitHub? (not a personal site in the form <username>.github.io, but a project site).
Also, can I give the GitHub repository a different name like fooproject.com, or does it something specific?
I suppose what I am really asking is, when hosting a website on GitHub...
Can you host your website using a GitHub repository of any name (like fooproject.com)?
If not, I'm aware of using gh-pages branches for the website of a project. How would this work with a custom domain?
If that isn't a good option either, what's the best option for my use case?
Hope that's clear.
So I managed to answer my own questions in the end - here's what I did.
My website is going to be something to showcase a different project I am working on. I could have hosted the website from a /doc directory or gh-pages branch in my project repository and then set up a custom domain from there.
However, there was also the option of creating a repository with any name and hosting the website from the master branch - this method appealed to me more.
I created a new repository named the same as my domain name, example.com (it doesn't really matter what you call the repository). Then, using git, I added some website files - index.html, stylesheet.css, etc.
Once my repository was ready, I configured its master branch as a publishing source for GitHub pages - see this help page for details.
Then with my DNS provider (GoDaddy, in my case), I configured the CNAME and A records (for the www subdomain and apex domain respectively). There are also help pages on GitHub for setting up www subdomains and setting up apex domains. Note that it takes a little while for the changes made on the DNS to take effect.
Finally, I added my custom domain to my GitHub repository - see the GitHub help page for adding or removing custom domains.
Here's a summary (for using any GitHub repository to host a website):
Create your repository - repository name doesn't matter.
Add your website files - HTML, CSS, JavaScript, etc.
Configure the master branch as a publishing source
Configure CNAME and A records with DNS provider
Add the custom domain to the GitHub repository settings

How do i manage content workflow for hexo site?

I've used static site generators like jekyll and had it hosted through github pages just fine using prose.io as a content management system.
I decided I wanted to go with a site using Hexo static site generator, but I cannot seem to figure out a good workflow for publishing content.
To my understanding this is the following in how I'd have to do it:
write *.md text file
hexo generate
(optional) hexo serve (to see local content)
hexo deploy (to publish the public content to whatever site using config.yml). Can publish on amazon S3, github pages, etc
Is there another workflow other than this?
the way I've been doing it before with jekyll+github pages is simply
go to prose.io
Write content
save (which publishes ocntent)
Ideally I'd like to use hexo+github pages the same way I do with jekyll+github pages.
Basically, can github generate static files automatically like it does with jekyll / ruby packages?
I figured out my own answer and posted it on my blog
http://www.tangycode.com/Quick-Start-Guide-To-Hexo-Install/
It covers everything you need to know on how to set up a hexo blog site and manage content workflows
One approach I am trying myself:
prose.io or similar to write and save on github repository
travis-ci.org to build hexo site and deploy
This is how it works:
Edit document on your editor of love
Commit it to your repository
travis-ci.org detects the commit and start working
My .travis.yml do (among few other things) the follow:
npm install hexo-cli
npm install grunt-cli
npm install inside site´s repository (hexo plugins and dependecies)
hexo generate
grunt deploy-production
hexo deploy (I use this to have a historic of the site stored in the repo itself)
If your editor of choice can direct commit to github repository your have exact same experience you had with Jekyll on GH pages. The advantage here is that you can use third-part plugin what GH pages avoid.
Alternatively, you can use INSTANT, which is a content management tool that you can use on any static website. You just install their javascript and can directly edit content in your website (without any admin dashboard). It saves and serves the content from the client. Pretty neat.
The easiest way is to use a hosting provider like Netlify in combination with a headless CMS, for example Headless (full disclore: I created it).
Netlify can do the build process for you and during that build process, it can fetch content from a headless CMS. Whenever you update content in the CMS, then Netlify does a rebuild.
Then you have your website on the Netlify CDN, a real CMS for your content management and you never need to dive in your code or github files. And that's all for free.