Skip to content

Commit

Permalink
Documentation website (#387)
Browse files Browse the repository at this point in the history
* fix tencentcloud unpublished version

* doc-site: initial doc site setup

* doc-site: react landing page

* doc-site: github actions deploy site

* doc-site: static docs and assets

* fix images closing tag

* doc-site: added page to navigate between modules

* doc-site: packaged common elements
  • Loading branch information
davidcheung committed Jul 6, 2021
1 parent da5ba4e commit 8fa5336
Show file tree
Hide file tree
Showing 94 changed files with 23,385 additions and 3 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/doc-site.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
## The is a combination of sites where
## Zero serves on the root of the domain /
## and module serves on /docs/modules/<path>/
# from the same S3 bucket

name: "Build Documentation Site"
on:
push:
branches:
- main
- doc-site
paths:
- doc-site/**

env:
region: us-west-2
s3_sync_path_to_exclude: docs/modules/*
s3_sync_path: ""
BUILD_DOMAIN: staging.getzero.dev
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup node.js
uses: actions/setup-node@v1
with:
node-version: 14.x
# - name: Documentaiton site folder
# run: cd doc-site
- name: Install Dependencies
working-directory: doc-site
run: npm install
- name: Build website
working-directory: doc-site
run: |
npm run build
pwd
ls -la
- name: Upload build artifact to Github
uses: actions/upload-artifact@v2
with:
name: build-artifact
path: doc-site/build

deploy:
name: Deploy
runs-on: ubuntu-latest
needs: build

steps:
# Once github action supports nested composite actions (anything `uses` is a composite action)
# Therefore we cannot reuse the code as a separate composite action until it supports it,
# current the deploy logic is in this file twice because of it
## https://github.com/actions/runner/issues/862
- uses: actions/checkout@v2
- name: Configure AWS credentials for S3 sync
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.ZERO_DOC_SITE_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.ZERO_DOC_SITE_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.region }}
- name: Download build artifact from Github
uses: actions/download-artifact@v1
with:
name: build-artifact
path: build/
- name: Sync with S3
shell: bash
run: |
cd build
aws s3 sync . "s3://${{ secrets.ZERO_DOC_SITE_BUCKET_NAME }}${{ env.s3_sync_path }}" --exclude "${{ env.s3_sync_path_to_exclude }}" --delete
- name: Invalidate Cloudfront
shell: bash
run: |
export DIST_ID=$(aws cloudfront list-distributions --query "DistributionList.Items[?Aliases.Items[?@=='${{ secrets.ZERO_DOC_SITE_BUCKET_NAME }}']].Id | [0]" | tr -d '"')
aws cloudfront create-invalidation --distribution-id ${DIST_ID} --paths "/*"
23 changes: 23 additions & 0 deletions doc-site/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Dependencies
/node_modules

# Production
/build

# Generated files
.docusaurus
.cache-loader

# Misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*

# to test theme color for elements locally
docs/about/color-test.md*
33 changes: 33 additions & 0 deletions doc-site/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Website

This website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator.

## Installation

```console
yarn install
```

## Local Development

```console
yarn start
```

This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.

## Build

```console
yarn build
```

This command generates static content into the `build` directory and can be served using any static contents hosting service.

## Deployment

```console
GIT_USER=<Your GitHub username> USE_SSH=true yarn deploy
```

If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.
3 changes: 3 additions & 0 deletions doc-site/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
};
12 changes: 12 additions & 0 deletions doc-site/docs/about/opensource.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
title: Opensource
sidebar_label: Opensource
sidebar_position: 2
---


## Contributing to Zero

Zero welcomes collaboration from the community; you can open new issues in our GitHub repo, Submit PRs' for bug fixes or browse through the tickets currently open to see what you can contribute too.

We use Zenhub to show us the entire project across all repositories, so if you are interested in seeing that or participating, you can can [check out our workspace](https://app.zenhub.com/workspaces/commit-zero-5da8decc7046a60001c6db44/board?repos=203630543,247773730,257676371,258369081,291818252,293942410,285931648,317656612)
95 changes: 95 additions & 0 deletions doc-site/docs/about/overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---
title: Overview
sidebar_label: Overview
sidebar_position: 1
---


## What is Zero

Zero is an open source tool which makes it quick and easy for startup technical founders and developers to build everything they need to launch and grow high-quality SaaS applications faster and more cost-effectively.

Zero sets up everything you need so you can immediately start building your product.

Zero was created by [Commit](https://commit.dev).
## Why is Zero good for startups

As a technical founder or the first technical hire at a startup, your sole focus is to build the logic for your application and get it into customers’ hands as quickly and reliably as possible. Yet you immediately face multiple hurdles before even writing the first line of code. You’re forced to make many tech trade-offs, leading to decision fatigue. You waste countless hours building boilerplate SaaS features not adding direct value to your customers. You spend precious time picking up unfamiliar tech, make wrong choices that result in costly refactoring or rebuilding in the future, and are unaware of tools and best practices that would speed up your product iteration.

Zero was built by a team of engineers with many years of experience in building and scaling startups. We have faced all the problems you will and want to provide a way for new startups to avoid all those pitfalls. We also want to help you learn about the tech choices we made so your team can become proficient in some of the great tools we have included. The system you get starts small but allows you to scale well into the future when you need to.

Everything built by Zero is yours. After using Zero to generate your infrastructure, backend, and frontend, all the code is checked into your source control repositories and becomes the basis for your new system. We provide constant updates and new modules that you can pull in on an ongoing basis, but you can also feel free to customize as much as you like with no strings attached. If you do happen to make a change to core functionality and feel like contributing it back to the project, we'd love that too!

It's easy to get started, the only thing you'll need is an AWS account. Just enter your AWS CLI tokens or choose your existing profile during the setup process and everything is built for you automatically using infrastructure-as-code so you can see exactly what's happening and easily modify it if necessary.

[Read about the day-to-day experience of using a system set up using Zero][real-world-usage]


## Why is Zero Reliable, Scalable, Performant, and Secure

Reliability: Your infrastructure will be set up in multiple availability zones making it highly available and fault tolerant. All production workloads will run with multiple instances by default, using AWS ELB and Nginx to load balance traffic. All infrastructure is represented with code using [HashiCorp Terraform][terraform] so your environments are reproducible, auditable, and easy to configure.

Scalability: Your services will be running in Kubernetes, with the EKS nodes running in an AWS [Auto Scaling Group][asg]. Both the application workloads and cluster size are ready to scale whenever the need arises. Your frontend assets will be stored in S3 and served from AWS' Cloudfront CDN which operates at global scale.

Security: Properly configured access-control to resources/security groups, using secret storage systems (AWS Secret Manager, Kubernetes secrets), and following best practices provides great security out of the box. Our practices are built on top of multiple security audits and penetration tests. Automatic certificate management using [Let's Encrypt][letsencrypt], database encryption, VPN support, and more means your traffic will always be encrypted. Built-in application features like user authentication help you bullet-proof your application by using existing, tested tools rather than reinventing the wheel when it comes to features like user management and auth.


## What do you get out of the box?
[Read about why we made these technology choices and where they are most applicable.][technology-choices]

[Check out some resources for learning more about these technologies.][learning-resources]

### Infrastructure
- Fully configured infrastructure-as-code AWS environment including:
- VPCs per environment (staging, production) with pre-configured subnets, security groups, etc.
- EKS Kubernetes cluster per environment, pre-configured with helpful tools like cert-manager, external-dns, nginx-ingress-controller
- RDS database for your application (Postgres or MySQL)
- S3 buckets and Cloudfront distributions to serve your assets
- Logging and Metrics collected automatically using either Cloudwatch or Prometheus + Grafana, Elasticsearch + Kibana
- VPN using [Wireguard][wireguard] (Optional)
- User management and Identity / Access Proxy using Ory [Kratos][kratos] and [Oathkeeper][oathkeeper] (Optional)
- Tooling to make it easy to set up secure access for your dev team
- Local/Cloud Hybrid developer environment using Telepresence (Optional)

### Backend
- Golang or Node.js example project automatically set up, Dockerized, and deployed to your new Kubernetes cluster
- CI pipeline built with [CircleCI][circleci] or GitHub Actions. Just merge a PR and a deploy will start. Your code will be built and tested, deployed to staging, then prompt you to push to production
- File upload / download support using signed Cloudfront URLs (Optional)
- Email support using [SendGrid][sendgrid] or AWS SES (Optional)
- Notification support for sending and receiving messages in your application (web, mobile, SMS, Email, etc.) (Optional) (In Progress)
- User management integration with Kratos and Oathkeeper - No need to handle login, signup, authentication yourself (Optional)

### Frontend
- React example project automatically set up, deployed and served securely to your customers
- CI pipeline built with CircleCI or GitHub Actions. Just merge a PR and a deploy will start. Your code will be built and tested, deployed to staging, then prompt you to push to production
- File upload / download support using signed Cloudfront URLs (Optional)
- User management integration with Kratos - Just style the example login / signup flow to look the way you want (Optional)
- Static site example project using Gatsby to easily make a landing page, also set up with a CI Pipeline using CircleCI (Optional)

<!-- internal links -->
[real-world-usage]: ./real-world-usage
[technology-choices]: ./technology-choices
[learning-resources]: ../reference/learning-resources
<!-- links -->


[git]: https://git-scm.com
[kubectl]: https://kubernetes.io/docs/tasks/tools/install-kubectl/
[terraform]:https://www.terraform.io/downloads.html
[jq]: https://github.com/stedolan/jq
[AWS CLI]: https://aws.amazon.com/cli/
[acw]: https://aws.amazon.com/cloudwatch/
[vpc]: https://aws.amazon.com/vpc/
[iam]: https://aws.amazon.com/iam/
[asg]: https://aws.amazon.com/autoscaling/
[zero binary]: https://github.com/commitdev/zero/releases/
[Wget]: https://stackoverflow.com/questions/33886917/how-to-install-wget-in-macos
[and more]: https://github.com/commitdev/zero-aws-eks-stack/blob/master/docs/resources.md
[terraform]: https://terraform.io
[letsencrypt]: https://letsencrypt.org/
[kratos]: https://www.ory.sh/kratos/
[oathkeeper]: https://www.ory.sh/oathkeeper/
[wireguard]: https://wireguard.com/
[circleci]: https://circleci.com/
[sendgrid]: https://sendgrid.com/
[launchdarkly]: https://launchdarkly.com/
49 changes: 49 additions & 0 deletions doc-site/docs/about/real-world-usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
title: Real-world Usage Scenarios
sidebar_label: Real-world Usage
sidebar_position: 4
---

## Developing and deploying application changes
1. Clone your git repository.
2. Make a branch, start working on your code.
3. If using the Telepresence dev experience, run the `start-dev-env.sh` script to allow you to use the hybrid cloud environment as you work, to run and test your code in a realistic environment.
3. Commit your finished code, make a PR, have it reviewed. Lightweight tests will run against your branch and prevent merging if they fail.
4. Merge your branch to the main branch. A build will start automatically.
5. The pipeline will build an artifact, run tests, deploy your change to staging, then wait for your input to deploy to production.

## Debugging a problem on production
1. Check the logs of your service:
- If using cloudwatch, log into the AWS console and go to the [Logs Insights tool](https://us-west-2.console.aws.amazon.com/cloudwatch/home#logsV2:logs-insights). Choose the log group for your production environment ending in `/application` and hit the "Run query" button.
- If using kibana, make sure you are on the VPN and open the Kibana URL in your browser. Click the "Discover" tab and try searching for logs based on the name of your service.
- Alternatively, watch the logs in realtime via the CLI using the command `kubectl logs -f -l app=<your service name>` or `stern <your service name>`
2. Check the state of your application pods. Look for strange events or errors from the pods:
```shell
$ kubectl get pods
$ kubectl get events
$ kubectl describe pods
```
3. Exec into your application pod. From here you can check connectivity with `ping` or `nc`, or inspect anything else application-specific.
```shell
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
your-service-6c5f6b56b7-2w447 1/1 Running 0 30m49s
$ kubectl exec -it your-service-6c5f6b56b7-2w447 sh
```


## Adding support for a new subdomain or site
1. Check the currently configured ingresses in your cluster:
```shell
$ kubectl get ingress -A
NAMESPACE NAME CLASS HOSTS ADDRESS PORTS AGE
your-service your-service <none> api.your-service.dev abcd1234-1234.us-west-2.elb.amazonaws.com 80, 443 130d
```
2. If this is for a new service entirely, make sure there is an ingress defined in the `kubernetes/` directory of your repo. If you want to add a new domain pointing to an existing service, just go into the file `kubernetes/overlays/<environment>/ingress.yml` and add a section to `spec:` and `tls:`, specifying your new domain.
- `spec` is where you can define the hostname, any special path rules, and which service you want traffic to be sent to
- if your hostname is in the `tls` section, a TLS certificate will automatically be provisioned for it using Let's Encrypt
3. A number of things will happen once this is deployed to the cluster:
- Routing rules will be created to let traffic in to the cluster and send it to the service based on the hostname and path
- An AWS load balancer will be created if one doesn't already exist and it will be pointed to the cluster
- In the case of a subdomain, a DNS record will be automatically created for you
- A certificate will be provisioned using Let's Encrypt for the domain you specified
9 changes: 9 additions & 0 deletions doc-site/docs/about/roadmap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: Roadmap
sidebar_label: Roadmap
sidebar_position: 5
---

:::info
Coming soon
:::
Loading

0 comments on commit 8fa5336

Please sign in to comment.