Skip to content

Commit

Permalink
Docs, deno based docker image & link label fix
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaRickli committed Dec 7, 2024
1 parent 54724ee commit 079cff1
Show file tree
Hide file tree
Showing 28 changed files with 763 additions and 282 deletions.
37 changes: 27 additions & 10 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,33 @@ jobs:
- name: Patch version
run: npm version ${{ github.ref_name }} --no-commit-hooks --no-git-tag-version

- name: Build frontend
- name: Build static app
run: deno task build
env:
BUILD_TARGET: static

- name: Release static build
shell: bash
env:
GITHUB_TOKEN: ${{ github.TOKEN }}
run: |
cd ${{github.workspace}}
cp LICENSE build/LICENSE
zip -r headnet-static-${{github.event.release.tag_name}}.zip build
gh release upload ${{github.event.release.tag_name}} headnet-static-${{github.event.release.tag_name}}.zip
- name: Build node app
run: deno task build

- name: Release node build
shell: bash
env:
GITHUB_TOKEN: ${{ github.TOKEN }}
run: |
cd ${{github.workspace}}
cp LICENSE build/LICENSE
zip -r headnet-node-${{github.event.release.tag_name}}.zip build
gh release upload ${{github.event.release.tag_name}} headnet-node-${{github.event.release.tag_name}}.zip
- name: Build versioned docker image
uses: docker/build-push-action@v5
Expand All @@ -59,17 +84,9 @@ jobs:

- name: Build latest docker image
uses: docker/build-push-action@v5
if: '!github.event.release.prerelease'
with:
context: .
platforms: linux/amd64,linux/arm64
tags: ghcr.io/rickli-cloud/headnet:latest
push: true

- name: Release build assets
run: |
cd ${{github.workspace}}
zip -r build-${{github.event.release.tag_name}}.zip build
gh release upload ${{github.event.release.tag_name}} build-${{github.event.release.tag_name}}.zip
env:
GITHUB_TOKEN: ${{ github.TOKEN }}
shell: bash
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ node_modules
.vercel
/.svelte-kit
/build
*.exe

# OS
.DS_Store
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM node:22-alpine
FROM denoland/deno:distroless

WORKDIR /opt/headnet
WORKDIR /app

COPY ./build .

EXPOSE 3000

CMD [ "node", "." ]
CMD [ "run", "--allow-env", "--allow-read=/app", "--allow-net=0.0.0.0:3000", "index.js" ]
137 changes: 129 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,155 @@
# Headnet

A web-ui for [Headscale](https://github.com/juanfont/headscale) with a focus on easy ACL management thru 3D network visualization.
[![Unstable release](https://github.com/rickli-cloud/headnet/actions/workflows/unstable.yaml/badge.svg)](https://github.com/rickli-cloud/headnet/actions/workflows/unstable.yaml)

## Developing
A web-ui for [Headscale](https://github.com/juanfont/headscale) with a focus on easy ACL management thru 3D network visualization

## Deploy

Headnet comes packaged in different ways ready to deploy

### Docker

Distroless docker container running deno

#### Tags

- `latest` Latest stable release
- `x.x.x` Release images
- `x.x.x-pre` Pre-release images (potentially unstable)
- `unstable` Built on every push to main

### Example

#### Docker run

```sh
docker run -d -p 3000:3000 ghcr.io/rickli-cloud/headnet:latest
```

#### Docker compose

Save this as `docker-compose.yaml`:

```yaml
version: '3.9'
name: headnet
services:
headnet:
image: ghcr.io/rickli-cloud/headnet:${HEADNET_VERSION:-latest}
container_name: headnet
pull_policy: always
restart: always
ports:
- 0.0.0.0:3000:3000/tcp
environment:
PUBLIC_MOCK_ENABLED: 'true' # Demo mode enabled
```
To circumvent CORS issues vite provides a dev proxy leading to your headscale instance. To enable this you have to define your headscale host as a environment variable.
Start it up:
```sh
docker compose up -d
```

### Static / Node

For all [releases](https://github.com/rickli-cloud/headnet/releases) there are zip archives provided for each build target

> The node server **is not capable of TLS** and is best used in combination with a reverse proxy. This does not pose a big security risk (assuming the internal network is somewhat secure) as no sensitive data is directly transmitted to this server.
## Environment configuration

> [!NOTE]
> When using the static build target the environment can be configured on buildtime or by modifying the `/_app/env.js` file.
> Example to enable mocking:
>
> ```js
> export const env = { PUBLIC_MOCK_ENABLED: 'true' };
> ```
### Base path
> Only affective during buildtime
```sh
# linux
export HEADSCALE_HOST="https://headscale.example.com"
export BASE_PATH="/admin"
# windows
$env:BASE_PATH="/admin"
```
### Build target

> Only affective during buildtime
With the help of SvelteKit adapters it is possible to target different environments. For now this includes:

- `node` Ready to serve requests running node or deno
- `static` Can be served using almost any webserver capable of serving static files (single page application)
- `auto` Let SvelteKit figure it out

```sh
# linux
export BUILD_TARGET="node"
# windows
$env:BUILD_TARGET="node"
```

### Development proxy

> Only affective during development
To circumvent CORS issues vite provides a dev proxy leading to your headscale instance. To enable this you have to define your headscale host as a environment variable

```sh
# linux
export HEADSCALE_HOST="https://headscale.example.com"
# windows
$env:HEADSCALE_HOST="https://headscale.example.com"
```

Once you've installed dependencies with `deno install`, start a development server:
### Mocking

Mock the whole API with the help of a service worker. This enables "demo mode"

```sh
# linux
export PUBLIC_MOCK_ENABLED="false"
# windows
$env:PUBLIC_MOCK_ENABLED="false"
```

## Install dependencies

Dependencies are required for building or developing

```sh
deno task dev
deno install
```

## Building

> To change the default base-url from `/admin` you have to set the environment variable `BASE_PATH` with your desired path before building the app.
Create a production build:

```sh
deno task build
```

You can preview the production build with `deno task preview`.
> [!TIP]
> You can use docker for building if you do not want to / cant install deno:
>
> ```sh
> docker run -it --rm --workdir /app -v ${PWD}:/app:rw --entrypoint /bin/sh denoland/deno:latest
> ```
## Developing
Start a development server:
```sh
deno task dev
```
## Stack

Expand Down
49 changes: 48 additions & 1 deletion deno.lock

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

Loading

0 comments on commit 079cff1

Please sign in to comment.