Skip to content

Commit

Permalink
new config format+workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
IncognitoTGT committed Jul 21, 2024
1 parent 4a8768e commit 0f18548
Show file tree
Hide file tree
Showing 6 changed files with 169 additions and 41 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/sync-type.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Update config types

on:
push:
branches: [ "main" ]

jobs:

update:

runs-on: ubuntu-latest
permissions: # Job-level permissions configuration starts here
contents: write # 'write' access to repository contents

steps:
- uses: actions/checkout@v4
- name: Pull the repository and update the config types
run: apt install curl; echo $(curl https://raw.githubusercontent.com/spaceness/stardust/main/src/types/config.d.ts) > stardust-config.d.ts
- name: Push changes
uses: stefanzweifel/git-auto-commit-action@v4
if: ${{ github.repository == 'spaceness/stardust-docs' && github.ref == 'refs/heads/main' }}
with:
commit_message: "chore: re-generate README sections"
commit_author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
branch: ${{ github.head_ref }}
7 changes: 4 additions & 3 deletions app/(home)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import landing from "@/app/_images/landing.gif"
import Image from "next/image";
export default function HomePage() {
return (
<main className="flex h-full flex-col items-center text-center">
<div className="text-2xl font-semibold mt-15">Stardust, the container streaming platform</div>
<div className="mt-5 text-muted-foreground">Stardust is a container streaming platform that allows you to stream your containers to any device, anywhere.</div>
<main className="flex h-full flex-col items-center text-center gap-4 mt-15">
<div className="text-2xl font-semibold">Stardust, the container streaming platform</div>
<div className="text-muted-foreground">Stardust is a container streaming platform that allows you to stream your containers to any device, anywhere.</div>
<Image src={landing} alt="Stardust" className="justify-self-center w-[80rem] h-[50rem] rounded-lg p-4" />

</main>
);
}
61 changes: 23 additions & 38 deletions content/docs/install/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,22 @@ title: Installing Stardust
description: Learn how to install Stardust on your machine.
---
import {Step, Steps} from "fumadocs-ui/components/steps"
import { AutoTypeTable } from 'fumadocs-typescript/ui';

Stardust is simple to setup, even for someone with zero IT knowledge.

Before you get started, make sure that you have the following already set up:
* Node.js 18 or later installed, plus `node-gyp` and `pnpm`. Download Node.js from [Nodesource](https://github.com/nodesource/distributions) and `node-gyp` and `pnpm` by running the following:
```bash
# or however else you install make and gcc
sudo apt install build-essential gcc
npm i -g pnpm node-gyp
```
* Docker setup. If you're using a Unix-based system, you can follow the instructions [here](https://docs.docker.com/engine/install/ubuntu/).
* A PostgreSQL database. You can use Docker to spin one up by running
```bash
docker run --name stardust-postgres -p 5432:5432 -e POSTGRES_PASSWORD=replaceme -d postgres
```
* An Auth0, Discord, GitHub, Google, Okta, Apple, and/or GitLab OAuth application.
* Docker setup (Stardust literally depends on Docker)

## Setup
<Steps>
Expand All @@ -25,7 +31,8 @@ docker run --name stardust-postgres -p 5432:5432 -e POSTGRES_PASSWORD=replaceme
<Step>
Block all container-to-container traffic (you need jq)
```bash
iptables -I FORWARD -s $(docker network inspect stardust | jq -r 'map(to_entries) | map ([.[6].value.Config[0].Subnet ]) | .[] | @tsv') -d $(docker network inspect stardust | jq -r 'map(to_entries) | map ([.[6].value.Config[0].Subnet ]) | .[] | @tsv') -j DROP
export DOCKER_NETWORK_SUBNET=$(docker network inspect stardust | jq -r 'map(to_entries) | map ([.[6].value.Config[0].Subnet ]) | .[] | @tsv')
iptables -I FORWARD -s $DOCKER_NETWORK_SUBNET -d $DOCKER_NETWORK_SUBNET -j DROP
```
</Step>
<Step>
Expand All @@ -36,43 +43,21 @@ docker run --name stardust-postgres -p 5432:5432 -e POSTGRES_PASSWORD=replaceme
```
</Step>
<Step>
Copy the `.env.example` file to `.env` and fill in the necessary details.
```bash
cp .env.example .env
Make a new file in `.config/config.json` and first, fill it with the following:
```json
{
"$schema": "config-schema.json",
}
```
and then the respective fields.
### General
`DATABASE_URL`: the connection string to your PostgreSQL database.

`METADATA_URL`: the public URL of your Stardust instance. Use this if you want to display site metadata.

`AUTH_SECRET`: a random string used to encrypt cookies. You can generate one by running `openssl rand -base64 32`.
### Docker
`DOCKER_TYPE`: how you're connecting to docker, either via `socket` or `tcp`, defaults to `socket`.

`DOCKER_PORT`: the port of your docker instance, this only applies if you're using `tcp`.

`CONTAINER_HOST`: the host of your docker instance, this only applies if you're using `tcp`.

`DOCKER_SOCKET`: the path to your docker socket, this only applies if you're using `socket`, defaults to `/var/run/docker.sock`.
### Auth
Make sure the redirect URIs in your OAuth applications are set to `<proto>://<domain>/api/auth/callback/[provider]`.

Also, make sure the scopes are set to allow read access to email and profile information.

ENV format is:
```
AUTH_[provider in all caps]_[key]
```
Keys are `ID`, `SECRET`, and `ISSUER`.


```sh title="Example .env"
AUTH_AUTH0_ID=your-auth0-id
AUTH_AUTH0_SECRET=your-auth0-secret
AUTH_AUTH0_ISSUER=your-auth0-issuer
```
`AUTH_PROVIDERS`: a comma-separated list of the providers you want to enable. Example: `AUTH_PROVIDERS=auth0,github,discord`.

<AutoTypeTable path="./stardust-config.d.ts" name="Config" />
### Session (`SessionConfig`)
<AutoTypeTable path="./stardust-config.d.ts" name="SessionConfig" />
### Docker (`DockerConfig`)
<AutoTypeTable path="./stardust-config.d.ts" name="DockerConfig" />
### Auth (`AuthConfig`)
<AutoTypeTable path="./stardust-config.d.ts" name="AuthConfig" />
</Step>
<Step>
Setup the database
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"dependencies": {
"fumadocs-core": "^10.1.3",
"fumadocs-mdx": "^8.2.30",
"fumadocs-typescript": "^2.0.1",
"fumadocs-ui": "^12.0.2",
"lucide-react": "^0.372.0",
"next": "^14.2.3",
Expand Down
19 changes: 19 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

97 changes: 97 additions & 0 deletions stardust-config.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
export interface Config {
/**
* The URL of the database to connect to.
*/
databaseUrl: string;
/**
* The public URL of your Stardust instance. Use this if you want to display site metadata.
*/
metadataUrl?: string;
docker: DockerConfig;
auth: AuthConfig;
session?: SessionConfig;
}

export interface DockerConfig {
/**
* The type of connection to use to connect to the Docker daemon.
* @default "socket"
*/
type?: "http" | "socket";
/**
* The path to the Docker socket to connect to, if using a socket connection.
* @default "/var/run/docker.sock"
*/
socket?: string;
/**
* The host to connect to, if using an HTTP connection.
*/
host?: string;
/**
* The port for the docker host, if using an HTTP connection.
*/
port?: number;
/**
* The Docker network used for connecting to containers
*/
network: string;
}

export interface AuthConfig {
/**
* The JWT secret used to sign tokens.
**/
secret: string;
/**
* Cloudflare turnstile configuration. Leave `undefined` to disable turnstile.
**/
turnstile?: {
secret: string;
siteKey: string;
};
/**
* Credentials configuration. Leave `undefined` to disable user/password signups.
**/
credentials?: {
/**
* Whether to allow user signups.
* @default false
**/
signups?: boolean;
};
/**
* OAuth configuration. Leave `undefined` to disable OAuth signups.
**/
oauth?: {
/**
* The OAuth providers to enable.
**/
providers: {
/**
* the provider name
**/
[key: string]: {
/**
* The client ID for the OAuth provider.
**/
clientId: string;
/**
* The client secret for the OAuth provider.
**/
clientSecret: string;
/**
* The OAuth provider's issuer, if applicable.
**/
issuer?: string;
};
};
};
}

export interface SessionConfig {
/**
* The amount of time to keep an inactive session alive for, in minutes.
* @default 1440
*/
keepaliveDuration?: number;
}

0 comments on commit 0f18548

Please sign in to comment.