Skip to content

Commit

Permalink
Merge pull request #107 from sinamics/Docusaurus
Browse files Browse the repository at this point in the history
Documentation site
  • Loading branch information
sinamics committed Aug 29, 2023
2 parents c8f6a41 + b26116c commit 3ecb9d4
Show file tree
Hide file tree
Showing 48 changed files with 14,643 additions and 29 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/docs-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build and Deploy Docusaurus

on:
push:
branches:
- main

paths:
- "docs/ztnet/**"

workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-latest
defaults:
run:
working-directory: docs/ztnet

steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 18
cache: npm

- name: Install dependencies
run: npm install

- name: Build website
run: npm run build

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build
user_name: github-actions[bot]
user_email: 41898282+github-actions[bot]@users.noreply.github.com

21 changes: 20 additions & 1 deletion docs/ztnet/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,21 @@
# Dependencies
/node_modules

# Production
/build

# Generated files
.docusaurus
node_modules
.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*

41 changes: 41 additions & 0 deletions docs/ztnet/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Website

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

### Installation

```
$ yarn
```

### Local Development

```
$ 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

```
$ yarn build
```

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

### Deployment

Using SSH:

```
$ USE_SSH=true yarn deploy
```

Not using SSH:

```
$ GIT_USER=<Your GitHub username> 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 docs/ztnet/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')],
};
40 changes: 40 additions & 0 deletions docs/ztnet/docs/Basics/info.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
sidebar_position: 4
---

# How ZTNET Works

## Overview

ZTnet is a web-based user interface developed in TypeScript, designed to facilitate easier management of ZeroTier networks. It works as an intermediary between the end-user and the ZeroTier Controller API, providing an intuitive interface for network management tasks.

## Core Components

### Frontend

The frontend is built using TypeScript along with modern web frameworks to offer an interactive and user-friendly experience.

### Backend

The backend acts as the bridge between the frontend and the ZeroTier Controller API, also written in TypeScript. It handles API requests and performs data transformation, making it easier to manage the network configurations.

## Communication Flow

1. **User Input**: The user performs actions on the ZTnet web UI.
2. **API Requests**: ZTnet translates these actions into API requests.
3. **ZeroTier Controller API**: These requests are sent to the ZeroTier Controller API for processing.
4. **API Responses**: The API sends back the data or status update.
5. **Display Data**: ZTnet then takes this information and updates the UI accordingly.

## ZeroTier API Reference

For more details about the API endpoints and data formats used, you can refer to the [ZeroTier API Documentation](https://docs.zerotier.com/service/v1/).

## Language and Libraries

- **Language**: TypeScript
- **Key Libraries**: React, Next.js

## Conclusion

Understanding the basic structure and flow of ZTnet can help both end-users and developers get the most out of the application. The modular design and the use of TypeScript make it scalable and easy to contribute to.
61 changes: 61 additions & 0 deletions docs/ztnet/docs/Contribute/info.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
sidebar_position: 5
---

# Developer

## Introduction

ZTnet uses a Development Container to simplify the development setup. This container orchestrates a development environment that includes PostgreSQL and ZeroTier, all configured through a `.devcontainer/docker-compose.yml` file. This setup ensures that the internal network remains consistent, making development easier and more efficient.

## Prerequisites

- Docker installed
- Docker Compose installed
- Visual Studio Code with the Remote - Containers extension

## Step-by-Step Guide to Start Development

### 1. Clone the Repository

```bash
git clone https://github.com/sinamics/ztnet.git
```

### 2. Navigate to Project Directory

```bash
cd ztnet
```

### 3. Open in Visual Studio Code

Open the project in Visual Studio Code.

### 4. Attach to Dev Container

- In Visual Studio Code, look for the "Remote Explorer" icon in the sidebar.
- Under the "Containers" section, you will see the Dev Container for this project.
- Right-click and choose "Attach to Container".


### 5. Install Dependencies

Once inside the container, navigate to your project folder and install the required Node.js dependencies.

```bash
npm install
```

### 6. Start the Development Server

```bash
npm run dev
```

Your ZTnet application should now be running in development mode. Any changes you make to the codebase will automatically be reflected in the application.

## Conclusion

Using a Development Container significantly streamlines the setup process, allowing you to focus more on developing features rather than setting up your environment. This also ensures that every developer works within a similar setup, reducing the "it works on my machine" problems.

70 changes: 70 additions & 0 deletions docs/ztnet/docs/Installation/_FreeBSD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
sidebar_position: 3
---

# Standalone FreeBSD

### Install PostgreSQL and ZeroTier
First, make sure PostgreSQL and ZeroTier are installed and configured on your FreeBSD server.
```bash
pkg install zerotier
pkg install postgresql13-server postgresql13-contrib
sysrc postgresql_enable=yes
service postgresql initdb
service postgresql start
```

### Install Node.js and npm
Next, install Node.js version 18.
```bash
curl -sL https://install-node.now.sh/lts | bash
```

### Setup Ztnet

1. Clone the Ztnet repository:
```bash
git clone https://github.com/sinamics/ztnet.git
```

2. Navigate into the directory:
```bash
cd ztnet
```

3. Checkout version:
```bash
git checkout tags/v0.3.6
```

4. Install the Node.js dependencies:
```bash
npm install
```

5. Create a `.env` file in the root directory and populate it with the necessary environment variables. Make sure these match what you've set up in your PostgreSQL database.
```
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres?schema=public
ZT_ADDR=http://localhost:9993
NEXT_PUBLIC_SITE_NAME=ZTnet
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="random_secret"
```
6. Populate the PostgreSQL database with the necessary tables:
```bash
npx prisma migrate deploy
npx prisma db seed
```
7. Build Next.js production:
```bash
npm run build
```
8. Run server:
```bash
cd .next/standalone
node server.js
```
7 changes: 7 additions & 0 deletions docs/ztnet/docs/Installation/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"label": "Installation",
"position": 1,
"link": {
"type": "generated-index"
}
}
83 changes: 83 additions & 0 deletions docs/ztnet/docs/Installation/debian_11.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
sidebar_position: 2
---

# Standalone Debian 11


### Install PostgreSQL and ZeroTier
First, make sure PostgreSQL and ZeroTier are installed and configured on your FreeBSD server.
```bash
curl -s https://install.zerotier.com | sudo bash
sudo apt install postgresql postgresql-contrib
```

Set a password for the PostgreSQL user. If you change the password, make sure to update the `DATABASE_URL` url variable in the `.env` file.
```bash
sudo -u postgres psql
\password postgres
```
### Install Node.js and npm
Next, install Node.js version 18.
```bash
curl -sL https://deb.nodesource.com/setup_18.x | sudo bash -
sudo apt-get install -y nodejs
```

### Copy necessary files
Copy mkworld binary to `/usr/local/bin/`:
```bash
cp ztnodeid/build/linux_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/')/ztmkworld /usr/local/bin/ztmkworld
```

### Setup Ztnet

1. Clone the Ztnet repository:
```bash
git clone https://github.com/sinamics/ztnet.git
```

2. Navigate into the directory:
```bash
cd ztnet
```

3. Checkout version:
```bash
git checkout tags/v0.3.6
````
4. Install the Node.js dependencies:
```bash
npm install
```

5. Create a `.env` file in the root directory and populate it with the necessary environment variables, Make sure these match what you've set up in your PostgreSQL database.
```
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres?schema=public
ZT_ADDR=http://localhost:9993
NEXT_PUBLIC_SITE_NAME=ZTnet
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="random_secret"
```
6. Populate the PostgreSQL database with the necessary tables:
```bash
npx prisma migrate deploy
npx prisma db seed
```
7. Build Next.js production:
```bash
npm run build
```
8. Run server:
```bash
cd .next/standalone
node server.js
```
Loading

0 comments on commit 3ecb9d4

Please sign in to comment.