Skip to content

Commit

Permalink
Docusaurus docs (#42)
Browse files Browse the repository at this point in the history
* deploy docusaurus docs
* add more infos to docs
* improve quickstart and requirements page
* add authenticatiion docs
* split env setup into several categories
* add info how to add pacman repo
* cleanup readme and add development.md
  • Loading branch information
Lukas-Heiligenbrunner authored Sep 29, 2024
1 parent 3df8bcf commit 6a0e3a4
Show file tree
Hide file tree
Showing 33 changed files with 9,213 additions and 139 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Deploy to GitHub Pages

on:
push:
branches:
- 'master'
workflow_dispatch:

jobs:
build:
name: Build Docusaurus
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./docs
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 18
cache: yarn
cache-dependency-path: './docs/yarn.lock'

- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build website
run: yarn build

- name: Upload Build Artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/build

deploy:
name: Deploy to GitHub Pages
needs: build

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
142 changes: 3 additions & 139 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,151 +21,15 @@

AURCache is a build server and repository for Archlinux packages sourced from the AUR (Arch User Repository). It features a Flutter frontend and Rust backend, enabling users to add packages for building and subsequently serves them as a pacman repository. Notably, AURCache automatically detects when a package is out of date and displays it within the frontend.

<p><img src="res/imgs/screenshot1.png" alt=""/>
<p><img src="docs/static/img/screenshot1.png" alt=""/>

<details>
<summary>More Images:</summary>
<br>
<img src="res/imgs/screenshot2.png" alt=""/>
<img src="res/imgs/screenshot3.png" alt=""/></p>
<img src="docs/static/img/screenshot2.png" alt=""/>
<img src="docs/static/img/screenshot3.png" alt=""/></p>
</details>

## Deployment with Docker and Docker-compose

To deploy AURCache using Docker and Docker-compose, you can use the following example docker-compose.yml file:

```yaml
version: '3'
services:
aurcache:
image: ghcr.io/lukas-heiligenbrunner/aurcache:latest
ports:
- "8080:8080"
- "8081:8081"
volumes:
- ./aurcache/db:/app/db
- ./aurcache/repo:/app/repo
privileged: true
```
Make sure to define the db path and repo path as volumes.
The default Port 8081 serves the Frontend and Port 8080 serves the Repository.
It needs to be a priviledged container to be able to use dind for spawining build containers.
If you are uncomfortable with the priviledged container you can pass through the docker socket and create a volume mounted to
`/app/builds` on aurcache container and set the `BUILD_ARTIFACT_DIR` environment variable to the volume.

For example:
```yaml
version: '3'
services:
aurcache:
image: ghcr.io/lukas-heiligenbrunner/aurcache:latest
ports:
- "8080:8080"
- "8081:8081"
volumes:
- ./aurcache/db:/app/db
- ./aurcache/repo:/app/repo
- /var/run/docker.sock:/var/run/docker.sock
- artifact_cache:/app/builds
environment:
- BUILD_ARTIFACT_DIR=artifact_cache # also absolute path is possible
volumes:
artifact_cache:
name: artifact_cache # this name should match env name above
driver: local
```

But keep in mind with this method containers are spawned on the host system and not in the aurcache container.
(And destroyed afterwards)

To start AURCache with Docker-compose, run:

```bash
docker-compose up -d
```

Access AURCache through your web browser at http://localhost:8081.

You can now start adding packages for building and utilizing the AURCache repository.

Add the following to your `pacman.conf` on your target machine to use the repo:

```bash
# nano /etc/pacman.conf
[repo]
SigLevel = Optional TrustAll
Server = http://localhost:8080/
```

### Docker Tags
`:git` - current master branch build

`:latest` - latest version

`:<version>` - <version> git tag (latest version = latest tag)
## Configuration
Environment Variables

| Variable | Type | Description | Default |
|------------------------|-----------------------|---------------------------------------------------------------------|---------------------------|
| DB_TYPE | (POSTGRESQL\| SQLITE) | Type of Database (SQLite, PostgreSQL) | SQLITE |
| DB_USER | String | POSTGRES Username (ignored if sqlite) | null |
| DB_PWD | String | POSTGRES Password (ignored if sqlite) | null |
| DB_HOST | String | POSTGRES Host (ignored if sqlite) | null |
| DB_NAME | String | Database name | 'db.sqlite' or 'postgres' |
| VERSION_CHECK_INTERVAL | Integer | Interval in seconds for checking package versions | 3600 |
| BUILD_ARTIFACT_DIR | String | pkg share directory between aurcache container and build containers | null |
| LOG_LEVEL | String | Log level | INFO |
| MAX_CONCURRENT_BUILDS | Integer | Max concurrent builds | 1 |
| CPU_LIMIT | Integer | CPU limit of build container in milli CPUs | 0 |
| MEMORY_LIMIT | Integer | Memory limit of build container in MB | -1 |
| JOB_TIMEOUT | Integer | Job timeout for build in Seconds | 3600 |
| OAUTH_AUTH_URI | String | Oauth authorize endpoint | null |
| OAUTH_TOKEN_URI | String | Oauth token endpoint | null |
| OAUTH_REDIRECT_URI | String | Oauth redirect uri back to AURCache | null |
| OAUTH_CLIENT_ID | String | Oauth client ID | null |
| OAUTH_CLIENT_SECRET | String | Oauth client Secret | null |
| SECRET_KEY | String | \>32Byte Random String for singing cookies | Random |

To disable Oauth support (default) leave all OAUTH_* variables undefined.
## Build Info

The AURCache project comprises two main components: a Flutter frontend and a Rust backend.
### Frontend (Flutter)

To build the Flutter frontend, ensure you have Flutter SDK installed. Then, execute the following commands:

```bash
cd frontend
flutter pub get
flutter build web
```

### Backend (Rust)

To build the Rust backend, make sure you have Rust installed. Then, navigate to the backend directory and run:

```bash
cd backend
cargo build --release
```

## Things still missing

* proper error return from api
* proper logging
* auto update packages
* implement repo-add in rust
* keep older pkg versions in repo (repo-add limitation)


## Contributors

Lukas-Heiligenbrunner

## License

This project is licensed under the MIT License. Feel free to contribute and modify as per the guidelines outlined in the license agreement.
20 changes: 20 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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*
41 changes: 41 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Website

This website is built using [Docusaurus](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/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')],
};
5 changes: 5 additions & 0 deletions docs/docs/Configuration/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"label": "Configuration",
"position": 3
}

16 changes: 16 additions & 0 deletions docs/docs/Configuration/authentication.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Authentication via OAuth2

AURCache supports OAuth2 authentication via various Oauth2 providers such as Authentik or Keycloak.
This allows you to restrict access to your AURCache instance to only users who have authenticated with one of these services.

Setup the following Environment Variables to enable OAuth2 authentication:

| Variable | Type | Description | Default |
|------------------------|-----------------------|---------------------------------------------------------------------|---------------------------|
| OAUTH_AUTH_URI | String | Oauth authorize endpoint | null |
| OAUTH_TOKEN_URI | String | Oauth token endpoint | null |
| OAUTH_REDIRECT_URI | String | Oauth redirect uri back to AURCache | null |
| OAUTH_CLIENT_ID | String | Oauth client ID | null |
| OAUTH_CLIENT_SECRET | String | Oauth client Secret | null |

To disable Authentiation leave all `OAUTH_*` variables undefined.
28 changes: 28 additions & 0 deletions docs/docs/Configuration/environment-variables.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
sidebar_position: 1
---

# Environment Variables
AURCache can be configured using the following environment variables:

## Database Configuration
| Variable | Type | Description | Default |
|------------------------|-----------------------|---------------------------------------------------------------------|---------------------------|
| DB_TYPE | (POSTGRESQL\| SQLITE) | Type of Database (SQLite, PostgreSQL) | SQLITE |
| DB_USER | String | POSTGRES Username (ignored if sqlite) | null |
| DB_PWD | String | POSTGRES Password (ignored if sqlite) | null |
| DB_HOST | String | POSTGRES Host (ignored if sqlite) | null |
| DB_NAME | String | Database name | 'db.sqlite' or 'postgres' |

## General Settings

| Variable | Type | Description | Default |
|------------------------|-----------------------|---------------------------------------------------------------------|---------------------------|
| VERSION_CHECK_INTERVAL | Integer | Interval in seconds for checking package versions | 3600 |
| BUILD_ARTIFACT_DIR | String | pkg share directory between aurcache container and build containers | null |
| LOG_LEVEL | String | Log level | INFO |
| MAX_CONCURRENT_BUILDS | Integer | Max concurrent builds | 1 |
| CPU_LIMIT | Integer | CPU limit of build container in milli CPUs | 0 |
| MEMORY_LIMIT | Integer | Memory limit of build container in MB | -1 |
| JOB_TIMEOUT | Integer | Job timeout for build in Seconds | 3600 |
| SECRET_KEY | String | \>32Byte Random String for singing cookies | Random |
5 changes: 5 additions & 0 deletions docs/docs/overview/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"label": "Overview",
"position": 1
}

24 changes: 24 additions & 0 deletions docs/docs/overview/development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Development
If you want to contribute to the project feel free to checkout the code and try to fix a bug or implement a feature.

## Build Info

The AURCache project comprises two main components: a Flutter frontend and a Rust backend.
### Frontend (Flutter)

To build the Flutter frontend, ensure you have Flutter SDK installed. Then, execute the following commands:

```bash
cd frontend
flutter pub get
flutter build web
```

### Backend (Rust)

To build the Rust backend, make sure you have Rust installed. Then, navigate to the backend directory and run:

```bash
cd backend
cargo build --release
```
22 changes: 22 additions & 0 deletions docs/docs/overview/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
sidebar_position: 1
---

# Introduction

AURCache is a build server and repository for Archlinux packages sourced from the AUR (Arch User Repository). It features a Flutter frontend and Rust backend, enabling users to add packages for building and subsequently serves them as a pacman repository. Notably, AURCache automatically detects when a package is out of date and displays it within the frontend.


## Advantages

- **Avoid repeated builds**: Build your packages only once on your server and not on every client.
- **Reduce CPU and memory usage**: Clients only need to download packages.
- **Reduce build time**: Build packages in parallel.
- **Reduce network traffic**: Serve packages from your local network.
- **Automatically update packages**: AURCache automatically checks for updates.
- **Customize your repository**: Add custom packages to your repository.

## Getting Started
Get started with [Quick Start](/docs/overview/quick-start) to try it out.

For advanced setup, see the [Configuration](/docs/configuration) page.
Loading

0 comments on commit 6a0e3a4

Please sign in to comment.