Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General QoL Improvements - Docker related #298

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 23 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
FROM python:3.12.3-alpine as base
WORKDIR /opt/hyperglass
ENV HYPERGLASS_APP_PATH=/etc/hyperglass
ENV HYPERGLASS_HOST=0.0.0.0
ENV HYPERGLASS_PORT=8001
ENV HYPERGLASS_DEBUG=false
ENV HYPERGLASS_DEV_MODE=false
ENV HYPERGLASS_REDIS_HOST=redis
ENV HYPEGLASS_DISABLE_UI=true
ENV HYPERGLASS_CONTAINER=true
COPY . .

FROM base as ui
WORKDIR /opt/hyperglass/hyperglass/ui
FROM python:3.12.3-alpine AS tools
RUN apk add build-base pkgconfig cairo-dev nodejs npm
RUN npm install -g pnpm

FROM tools AS base
ENV HYPERGLASS_APP_PATH=/etc/hyperglass \
HYPERGLASS_HOST=0.0.0.0 \
HYPERGLASS_PORT=8001 \
HYPERGLASS_DEBUG=false \
HYPERGLASS_DEV_MODE=false \
HYPERGLASS_REDIS_HOST=redis \
HYPEGLASS_DISABLE_UI=true \
HYPERGLASS_CONTAINER=true

FROM base AS deps
# JS Dependencies for UI
WORKDIR /opt/hyperglass/hyperglass/ui
COPY hyperglass/ui/package.json .
COPY hyperglass/ui/pnpm-lock.yaml .
RUN pnpm install -P

FROM ui as hyperglass
# Python Dependencies for Backend
WORKDIR /opt/hyperglass
RUN pip3 install -e .
COPY README.md .
COPY pyproject.toml .
RUN pip install -e .

FROM deps AS hyperglass
COPY . .
EXPOSE ${HYPERGLASS_PORT}
CMD ["python3", "-m", "hyperglass.console", "start"]
22 changes: 22 additions & 0 deletions compose-self.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
services:
kv-storage:
image: "valkey/valkey:8-alpine"

hyperglass:
build: .
depends_on:
- kv-storage
environment:
- HYPERGLASS_APP_PATH=/etc/hyperglass
- HYPERGLASS_REDIS_HOST=${HYPERGLASS_REDIS_HOST-kv-storage}
- HYPERGLASS_HOST=${HYPERGLASS_HOST-0.0.0.0}
- HYPERGLASS_PORT=${HYPERGLASS_PORT-8001}
- HYPERGLASS_DEBUG=${HYPERGLASS_DEBUG-false}
- HYPERGLASS_DEV_MODE=${HYPERGLASS_DEV_MODE-false}
- HYPEGLASS_DISABLE_UI=${HYPEGLASS_DISABLE_UI-false}
- HYPERGLASS_CONTAINER=${HYPERGLASS_CONTAINER-true}
- HYPERGLASS_ORIGINAL_APP_PATH=${HYPERGLASS_APP_PATH}
ports:
- "${HYPERGLASS_PORT-8001}:${HYPERGLASS_PORT-8001}"
volumes:
- ${HYPERGLASS_APP_PATH-/etc/hyperglass}:/etc/hyperglass
14 changes: 8 additions & 6 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
services:
redis:
image: "redis:alpine"
kv-storage:
image: "valkey/valkey:8-alpine"

hyperglass:
image: ghcr.io/thatmattlove/hyperglass:main
restart: unless-stopped
depends_on:
- redis
- kv-storage
environment:
- HYPERGLASS_APP_PATH=/etc/hyperglass
- HYPERGLASS_REDIS_HOST=${HYPERGLASS_REDIS_HOST-kv-storage}
- HYPERGLASS_HOST=${HYPERGLASS_HOST-0.0.0.0}
- HYPERGLASS_PORT=${HYPERGLASS_PORT-8001}
- HYPERGLASS_DEBUG=${HYPERGLASS_DEBUG-false}
- HYPERGLASS_DEV_MODE=${HYPERGLASS_DEV_MODE-false}
- HYPERGLASS_REDIS_HOST=${HYPERGLASS_REDIS_HOST-redis}
- HYPEGLASS_DISABLE_UI=${HYPEGLASS_DISABLE_UI-false}
- HYPERGLASS_CONTAINER=${HYPERGLASS_CONTAINER-true}
- HYPERGLASS_ORIGINAL_APP_PATH=${HYPERGLASS_APP_PATH}
build: .
ports:
- "${HYPERGLASS_PORT-8001}:${HYPERGLASS_PORT-8001}"
volumes:
- ${HYPERGLASS_APP_PATH-/etc/hyperglass}:/etc/hyperglass
- ./data:/etc/hyperglass
1 change: 1 addition & 0 deletions docs/pages/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Cards } from "nextra/components";

<Cards>
<Cards.Card href="installation/docker" title="Using Docker" />
<Cards.Card href="installation/docker-ghcr" title="Using Docker (GHCR)" />
<Cards.Card href="installation/manual" title="Manual Installation" />
</Cards>

Expand Down
49 changes: 49 additions & 0 deletions docs/pages/installation/docker-ghcr.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
title: Using Docker
description: Installing hyperglass with Docker
---

import { Cards, Steps, Callout } from "nextra/components";
// import { Callout } from "nextra-theme-docs";

<Callout type="info">**Docker is the recommended method for running hyperglass.**</Callout>

<Steps>

### Install Docker

<Cards>
<Cards.Card
title="Docker Engine Installation Guide"
href="https://docs.docker.com/engine/install/"
target="_blank"
arrow
/>
</Cards>

### Download hyperglass

```shell copy
mkdir /home/hyperglass
cd /home/hyperglass
wget "https://github.com/thatmattlove/hyperglass/blob/main/compose.yaml"
```

### Optional: Quickstart

Do this if you just want to see the hyperglass page working with a fake device.

```shell copy
mkdir data
wget -O ./data/devices.yaml "https://raw.githubusercontent.com/thatmattlove/hyperglass/refs/heads/main/.samples/sample_devices.yaml"
docker compose up
```

Navigate to http://IPADDRESS:8001

### Enable auto-restart

You may want to ensure that Hyperglass stays running even after a reboot.
To do this, you can easily change the "restart" parameter in `compose.yaml` to `always`.

</Steps>