The author | | Jiang Yu source alibaba cloud native public number
If you eat your own dog food, your own food is not 🐶. Serverless Devs has experienced several months since its inception. In these months, Serverless Devs has grown rapidly, largely because “we are eating our own dog food”. We believe that if we are not comfortable with things, it will be difficult for everyone to use them.
Today’s article is about the construction of Serverless Devs official website. It is very simple and interesting.
What is Serverless Devs?
“Serverless Devs” is the open source Serverless developer platform of Ali Cloud, which is committed to providing powerful tool chain system for developers. Through this platform, developers can experience multi-cloud Serverless products with one click and deploy Serverless projects at a fast speed. Serverless Devs allows developers to experience Serverless products from multiple mainstream cloud vendors in a shorter path, create and deploy Serverless applications in a faster speed, and manage projects and operations in a simpler and more automated way. When the Serverless project is fully automated through this platform, it can save 99.9% in administration costs.
- Making address: https://github.com/serverless-devs
- Gitee address: https://gitee.com/organizations/serverless-devs/projects
- Serverless Devs official website: https://www.serverless-devs.com
Serverless Devs and Docusaurus
As we all know, the official website of open source project should not be too complicated, in fact, simple is good, so we finally chose Docusaurus as the framework selection of the official website after a long time of comparison. So the question comes, after the selection is over, how do we build the official website?
After some simple research, we decided to use Serverless Devs to build the Serverless Devs official website and deploy it on the Serverless architecture. However, this process is really classic:
Docusaurus is initialized with Serverless devs: s init devsapp/website- Docusaurus https://github.com/devsapp/website-example.
To be honest, it’s only a single line of code, but the whole initialization is quite pleasing. Serverless Devs does a lot of work on scaffolding and bootstrasing as a Serverless application lifecycle tool:
As you can see, when initializing, the system asks us to fill in the project name, bucket name, and required key information, and then tells us:
You could [cd /Users/jiangyu/Desktop/start-fc/website/serverless-website] and enjoy your serverless journey!
Copy the code
It was kind of sweet.
Next, follow the guidelines:
You can see the help documentation:
When you run the help message for the first time after executing s website-starter -h, the component loading process may be involved. Wait for a moment and you can see the help message:
At this point, we need to deploy the project online by executing S deploy.
Of course, we still need to configure the project and build our official website.
For website construction, you can refer to Docusaurus’ official website documents. For website component configuration of Serverless Devs, you can refer to the above picture to give us 🧭 More information: github.com/devsapp/web…
You can learn more about the configuration in the documentation, resulting in our S.yaml:
Edition: 1.0.0 Access: website_Access Services: website: Component: devsapp/website Actions: pre-deploy: -run: npm install path: ./ - run: npm run build path: ./ props: bucket: serverless-devs-website src: codeUri: ./ publishDir: ./build index: index.html subDir: type: index region: cn-hongkongCopy the code
CD and Serverless Devs
When we set up the website page and it was running locally and deployed with the local DEPLOY, we faced a new problem: how do I update my website? Do I have to manually publish locally every time? Is it possible to access automation capabilities using Github Actions?
So:
- We created a repository:Github.com/Serverless-…
- After we pushed the code to the repository, we created a Github Action configuration:
name: Website Publish
on:
push:
branches: [ master ]
jobs:
publish-website:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 12
registry-url: https://registry.npmjs.org/
- run: npm install
- run: npm install -g @serverless-devs/s
- run: s config add --AccountID ${{secrets.ALIYUN_ACCOUNT_ID}} --AccessKeyID ${{secrets.ALIYUN_ACCESS_KEY_ID}} --AccessKeySecret ${{secrets.ALIYUN_ACCESS_KEY_SECRET}} -a website_access
- run: s deploy
Copy the code
At this point, I push the code, and the site will be published automatically.
The core points are as follows:
- Serverless Devs: run: NPM install -g @serverless- Devs /s
- To configure key information, run: ALIYUNACCOUNTID−−AccessKeyID{{secrets.aliyun_account_id}} –AccessKeyID Secrets. ALIYUNACCOUNTID – – AccessKeyID {{secrets. ALIYUN_ACCESS_KEY_ID}} – AccessKeySecret ${{secrets.ALIYUN_ACCESS_KEY_SECRET}} -a website_access
- Deploy: run: s deploy
Overall effect:
Page after deployment:
Here it should be noted that the key information is configured using Github Secrets function, which is relatively basic, so it will not be described here, mainly is to release the required key information to configure Secrets.
conclusion
In fact, at present, many people’s blogs, part of the official website are deployed through static websites, etc., Serverless Devs is more convenient to go through this set:
- Thanks to the behavior description of Serverless Devs, it is easier to integrate NPM Install, NPM Run build, and other directives into projects.
- Thanks to Serverless Devs’ bootstrap capabilities, including creation, getting started, and fetching links during key configuration, Serverless Devs is really constantly working on the details for convenience.
- Thanks to the flexibility of Serverless Devs, Github’s CD capability can be configured with just two or three lines of code to continuously send the site, which I find quite cool.
Of course, there are still some issues that need to be addressed:
- The Serverless Devs scenario remains to be enriched.
- There is only CD on the official website of this community, but there is still a certain risk without CI, so we need to improve it gradually.