-
Notifications
You must be signed in to change notification settings - Fork 60
[Draft] Branch based Multi version Approach
Following are the expectations -
-
- contribute in Documentation.
-
- contribute in docs & marketing landing pages
- do build promotions
- PR reviews
The Current Docs site building repo will be divided into 2 repos
This repo contains docs content source code ( .md files) Eg - https://github.com/dev-sunbird/docs. This repo will have multiple branches where each branch will represent a product version. Master branch is the default branch and represent the upcoming / draft version. To release a version one will have to create a version branch from the master branch. Each branch will contain a version.yaml file which will store the information like -
- Landing Pages Sections / blocks - Section / blocks title , image src, URL
- Sidebar data
- Link to version.yaml file - https://github.com/dev-sunbird/docs/blob/master/version.yaml
This repo contains site building code (Jekyll and Marketing Landing Pages) Eg - https://github.com/dev-sunbird/dev-sunbird.github.io . Along with Jekyll Code this will contain -
- Branches.yaml - This yaml file works like a controlling unit of versions. This stores information such as -
- What all branches / version are to be included in the build
- Which version is the latest version, published and are allowed to index in search engines.
- Link to branch.yaml file - https://github.com/dev-sunbird/dev-sunbird.github.io/blob/dev/_data/branches.yaml
- Some Shell scripts - to make docs repo code ready for Jekyll builds based on information provided in branches.yaml file. Basically fetching those version branches and placing them at right place to make Jekyll builds feasible.
Processes are same as the current prod has
- Contributor Clicks on edit page link
- does modifications on github
- sends PR
- modified pages urls is added in pr comments
- Reviewer and Contributor can reviews the output of pr
- Reviewer does necessary changes if any issues found or changes requested by reviewer
- Pr is merged by Reviewer
- builds are promoted by Docs Team
- Contributor requests for new page by adding issue on github
- Docs team creates a new md file at appropriate place and share link to contributor
- Contributor contributes content
- Sends pr
- added pages urls is added in pr comments
- Reviewer and contributor can reviews the output of pr
- Reviewer does necessary changes if any issues found or changes requested by reviewer
- Pr is merged by reviewer
- Reviewer or docs team adds link in sidebar if required
- Builds are promoted by docs team
- Docs team works on master branch for upcoming versions. Necessary information is updated in md files and version.yaml file
- Once the version is ready, a new branch is created from the master branch.
- Version specific details are added in branches.yaml file of site repo
- Review site is generated . Site is reviewed
- Builds are promoted after reviewing
- Docs team creates a tag with prefix “releases-” on site repo
- Release site is created
- Release site is reviewed
- If release site is good to go on prod then, the CircleCI workflow is approved to deploy on prod
- Artifacts from release site is promoted to the prod
- If release site was not good to go prod then necessary changes are done in docs or site repo until the release is good to go.
This is same as current prod
Docs Repo
- PR raised - For each pr raised a pr preview site will be created Eg - pr-19.sunbird.org
- PR merged - If PR is merged it will trigger the review build of site repo and deploy to dev instance dev.sunbird.org
Site Repo
- Commits - it will trigger the review build and deploy to dev.sunbird.org
- Release tag - this will create a site Eg - release-1.2.0.sunbird.org for each releases
- Fetch site repo code
- Run script to fetch docs repo code based on info provided in branches.yaml
- Process fetched docs repo code to make them feasible for Jekyll builds
- Build Site
- Deploy - This will move the build site to the dev server in their respective folders. like
- For PR the folder will be pr- Eg : pr-21
- For release the folder will be release tag Eg: release-1.2.5
- Dev folder will keep updated from the review trigger of site repo.
Nginx of development server needs to be configured such that each subdomain request should be served from their respective folders. So subdomain request should be handled such that it looks for the folder if available with the subdomain name in var/www/ directory. If available then point the the directory else redirect to the dev.sunbird.org. This configuration should be wildcard. Eg -
- pr-19.sunbird.org should point to var/www/pr-19 folder
- pr-20.sunbird.org should point to var/www/pr-20 folder
- release-1.4.5.sunbird.org should point to the var/www/release-1.4.5 folder
Some references -
- Current deployment process involves deployment of all non-prod sites inside the sub-directories of a S3 Bucket.
- Preview sites of PR goes in http://sunbird-docs-qa.s3-website.ap-south-1.amazonaws.com/pr/
- Release site goes in http://sunbird-docs-qa.s3-website.ap-south-1.amazonaws.com/releases/
Problem Statement -
- dev.com/releases/1/ and dev.com/releases/2/ are two different sites as per the single bucket deployment process.so when one is navigating the dev.com/releases/1 site then all the relative urls should navigate to the dev.com/releases/1 pages only.
- In usual cases base tag is not defined in the head sections. So the the Page URL itself becomes the base URL for that page.
- Example 1 - let
site.com/docs/architecture/
be a page andcss/style.css
file makes that page beautiful , so in this case following things will happen -- Since base URL of the page is not defined, so the base url will become -
site.com/docs/architecture/
- Since the base URL is
site.com/docs/architecture/
and css href iscss/style.css
the css file will be looked atsite.com/docs/architecture/css/style.css
rather than atsite.com/css/style.css
so the page will not render properly. This can be fixed in two ways - - Approach 1 - If we append a '/' in the beginning of css href, than the css file will be looked from the root of the server i.e.
site.com/css/style.css
than it will start rendering properly . - Approach 2 - we add base url '/' on all pages so that it starts rendering properly .but it will add an side effect i.e. all relative paths will start from the serve root rather than the page itself so the more or less it has became the absolute path.
- Since base URL of the page is not defined, so the base url will become -
- Example 1 - let
- Example 2 - Now lets consider folder-ed deployment process we follow - Let dev.com/releases/1/ be a site,
dev.com/releases/1/docs/architecture/
be a page and 'css/style.css' makes page beautiful , so in this case following things will happen -- Since base URL of the page is not defined, so the base url will become -
dev.com/releases/1/docs/architecture/
- Since the base URL is
dev.com/releases/1/docs/architecture/
and css href iscss/style.css
the css file will be looked atdev.com/releases/1/docs/architecture/css/style.css
rather than atdev.com/releases/1/css/style.css
so the page will not render properly.Now lets try solutions of previous case - - - Approach 1 - If we append a '/' in the beginning of css href, than the css file will be looked from the root of the server i.e.
dev.com/css/style.css
rather thandev.com/releases/1/css/style.css
and hence not a solution . - Approach 2 - we add base url '/' on all pages.But this will make all pages relative to the server root. hence not a solution.so the css href will become
dev.com/css/style.css
- Approach 3 - we add base url '/releases/1/' as base url so the all url will become relative to
dev.com/releases/1/
rather thandev.com
this somehow helps in relative path problem but next thing arises is When release 1 is promoted to the prod - rather then rebuilding the site, the generated site of dev.com/releases/1 should move to the prod. i.e. same code should work in both scenarios - when in root or within some folder. But it fails. We can fix it with the help of JS by checking the host and modifying the base url accordingly but the build promotion concept fails as the environment behaviour is changed. Another thing is it becomes even worse when the multi-version docs comes in picture where we expect to add relative path from docs version landing page rather than from the site baseurl. - Approach 4 - Deploying in sub-domains this resolves the baseurl problem but the problem is aws s3 sindle bucket doesn't support sub-domains out of the box.
- Since base URL of the page is not defined, so the base url will become -
AWS S3 doesn't support the wildcard sub-domain from the sub-directories.
Possible solution is deploying code to the proxy server which serves the subdomain content from the respective directories. This serving should be wildcard so that it serves any dynamically created folders.