Skip to content

Commit 0cc32b7

Browse files
committed
More setup info
1 parent 05b427c commit 0cc32b7

File tree

6 files changed

+36
-4
lines changed

6 files changed

+36
-4
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
JWT_SECRET='your-secret-key-here'

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ data/**
1010
kernel
1111
kernel/**
1212
bin/**
13+
.env
14+
tmp
15+
tmp/**

README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,25 @@ Run containerized workloads in VMs, powered by [Cloud Hypervisor](https://github
88

99
### Prerequisites
1010

11-
- Go 1.25.4+
12-
- Cloud Hypervisor
13-
- containerd
11+
**Cloud Hypervisor** - [Installation guide](https://www.cloudhypervisor.org/docs/prologue/quick-start/#use-pre-built-binaries)
12+
```bash
13+
cloud-hypervisor --version # Verify
14+
ch-remote --version
15+
```
16+
17+
**containerd** - [Installation guide](https://github.com/containerd/containerd/blob/main/docs/getting-started.md)
18+
```bash
19+
containerd --version # Verify
20+
```
21+
22+
**Go 1.25.4+** and **KVM**
23+
24+
### Configuration
25+
26+
```bash
27+
cp .env.example .env
28+
# Edit .env and set JWT_SECRET
29+
```
1430

1531
### Build
1632

cmd/api/config/config.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package config
22

33
import (
44
"os"
5+
6+
"github.com/joho/godotenv"
57
)
68

79
type Config struct {
@@ -15,8 +17,13 @@ type Config struct {
1517
DNSServer string
1618
}
1719

20+
// Load loads configuration from environment variables
21+
// Automatically loads .env file if present
1822
func Load() *Config {
19-
return &Config{
23+
// Try to load .env file (fail silently if not present)
24+
_ = godotenv.Load()
25+
26+
cfg := &Config{
2027
Port: getEnv("PORT", "8080"),
2128
DataDir: getEnv("DATA_DIR", "/var/lib/hypeman"),
2229
BridgeName: getEnv("BRIDGE_NAME", "vmbr0"),
@@ -26,6 +33,8 @@ func Load() *Config {
2633
JwtSecret: getEnv("JWT_SECRET", ""),
2734
DNSServer: getEnv("DNS_SERVER", "1.1.1.1"),
2835
}
36+
37+
return cfg
2938
}
3039

3140
func getEnv(key, defaultValue string) string {

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ require (
88
github.com/go-chi/chi/v5 v5.2.3
99
github.com/golang-jwt/jwt/v5 v5.3.0
1010
github.com/google/wire v0.7.0
11+
github.com/joho/godotenv v1.5.1
1112
github.com/oapi-codegen/runtime v1.1.2
1213
github.com/stretchr/testify v1.11.1
1314
golang.org/x/sync v0.17.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU=
2323
github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
2424
github.com/google/wire v0.7.0 h1:JxUKI6+CVBgCO2WToKy/nQk0sS+amI9z9EjVmdaocj4=
2525
github.com/google/wire v0.7.0/go.mod h1:n6YbUQD9cPKTnHXEBN2DXlOp/mVADhVErcMFb0v3J18=
26+
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
27+
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
2628
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
2729
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
2830
github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE=

0 commit comments

Comments
 (0)