mirror of
https://git.numenor-labs.us/dsfx.git
synced 2025-04-29 00:00:35 +00:00
chore(project): redo binary structure
This commit is contained in:
parent
e22e9c6fae
commit
336b371449
@ -4,7 +4,7 @@ WORKDIR /app
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN GOOS=linux CGO_ENABLED=0 go build -o /app/dsfx ./cmd/dsfxnode
|
||||
RUN GOOS=linux CGO_ENABLED=0 go build -o /app/dsfx ./cmd/dsfx
|
||||
|
||||
FROM scratch
|
||||
|
||||
|
@ -12,7 +12,7 @@ _DSFX is a next generation file exchange that that liberates users from big tech
|
||||
|
||||
```bash
|
||||
# Run a server
|
||||
go run koti.casa/numenor-labs/dsfx/cmd/dsfxnode@latest
|
||||
go run koti.casa/numenor-labs/dsfx/cmd/dsfx@latest
|
||||
# serving: dsfx://0.0.0.0:8000#<ed25519_public_key>
|
||||
|
||||
# Get the client
|
||||
|
@ -1,9 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"context"
|
||||
"log/slog"
|
||||
|
||||
"koti.casa/numenor-labs/dsfx/internal/lib/disk"
|
||||
"koti.casa/numenor-labs/dsfx/internal/lib/system"
|
||||
"koti.casa/numenor-labs/dsfx/internal/peer/node"
|
||||
|
||||
"koti.casa/numenor-labs/dsfx/internal/lib/storage/scoped"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.Println("hello from dsfx!")
|
||||
ctx := context.Background()
|
||||
|
||||
sys := system.Default()
|
||||
|
||||
configDir := sys.GetEnv("DSFXNODE_CONFIG_DIR")
|
||||
if configDir == "" {
|
||||
configDir = "/etc/dsfxnode/config"
|
||||
}
|
||||
configScope := scoped.New(disk.Default(), configDir)
|
||||
|
||||
err := node.New(configScope, sys).Run(ctx)
|
||||
if err != nil {
|
||||
// Log the error and exit with a non-zero status code.
|
||||
slog.Error("Error running dsfxnode", slog.Any("error", err))
|
||||
sys.Exit(1)
|
||||
}
|
||||
}
|
||||
|
@ -1,31 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
|
||||
"koti.casa/numenor-labs/dsfx/internal/lib/disk"
|
||||
"koti.casa/numenor-labs/dsfx/internal/lib/system"
|
||||
"koti.casa/numenor-labs/dsfx/internal/peer/node"
|
||||
|
||||
"koti.casa/numenor-labs/dsfx/internal/lib/storage/scoped"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ctx := context.Background()
|
||||
|
||||
sys := system.Default()
|
||||
|
||||
configDir := sys.GetEnv("DSFXNODE_CONFIG_DIR")
|
||||
if configDir == "" {
|
||||
configDir = "/etc/dsfxnode/config"
|
||||
}
|
||||
configScope := scoped.New(disk.Default(), configDir)
|
||||
|
||||
err := node.New(configScope, sys).Run(ctx)
|
||||
if err != nil {
|
||||
// Log the error and exit with a non-zero status code.
|
||||
slog.Error("Error running dsfxnode", slog.Any("error", err))
|
||||
sys.Exit(1)
|
||||
}
|
||||
}
|
@ -39,16 +39,16 @@ git clone https://koti.casa/numenor-labs/dsfx.git
|
||||
|
||||
cd dsfx
|
||||
|
||||
go build -o <installation-target> ./cmd/dsfxnode
|
||||
go build -o <installation-target> ./cmd/dsfx
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
DSFX uses the following environment variables to configure its behavior:
|
||||
|
||||
| Variable | Description | Default Value |
|
||||
| -------------------- | ----------------------------------------------------------- | -------------------- |
|
||||
| DSFXNODE_PORT | The port on which the DSFX server will listen | 8000 |
|
||||
| DSFXNODE_HOST | The host on which the DSFX server will run | 0.0.0.0 |
|
||||
| DSFXNODE_CONFIG_DIR | The directory where the DSFX configuration files are stored | /etc/dsfxnode/config |
|
||||
| DSFXNODE_STORAGE_DIR | The directory where the DSFX storage files are stored | /etx/dsfxnode/data |
|
||||
| Variable | Description | Default Value |
|
||||
| ---------------- | ----------------------------------------------------------- | ---------------- |
|
||||
| DSFX_HOST | The host on which the DSFX server will run | 0.0.0.0 |
|
||||
| DSFX_PORT | The port on which the DSFX server will listen | 8000 |
|
||||
| DSFX_CONFIG_DIR | The directory where the DSFX configuration files are stored | /etc/dsfx/config |
|
||||
| DSFX_STORAGE_DIR | The directory where the DSFX storage files are stored | /etx/dsfx/data |
|
||||
|
@ -3,8 +3,10 @@ package conf
|
||||
import "koti.casa/numenor-labs/dsfx/internal/lib/system"
|
||||
|
||||
const (
|
||||
// DefaultConfigDir is the default directory for the dsfxctl configuration.
|
||||
DefaultConfigDir = "/etc/dsfxnode/config"
|
||||
// DefaultConfigDir is the default directory for the dsfx configuration.
|
||||
DefaultConfigDir = "/etc/dsfx/config"
|
||||
// DefaultStorageDir is the default directory for the dsfx storage.
|
||||
DefaultStorageDir = "/etc/dsfx/data"
|
||||
// DefaultHost is the default host for the dsfxctl application.
|
||||
DefaultHost = "0.0.0.0"
|
||||
// DefaultPort is the default port for the dsfxctl application.
|
||||
@ -14,7 +16,8 @@ const (
|
||||
// Conf holds the configuration for the dsfxctl application.
|
||||
type Conf struct {
|
||||
// Directories
|
||||
ConfigDir string
|
||||
ConfigDir string
|
||||
StorageDir string
|
||||
// Networking
|
||||
Host string
|
||||
Port string
|
||||
@ -23,17 +26,22 @@ type Conf struct {
|
||||
func FromSystem(sys system.System) Conf {
|
||||
var c Conf
|
||||
|
||||
c.ConfigDir = sys.GetEnv("DSFXNODE_CONFIG_DIR")
|
||||
c.ConfigDir = sys.GetEnv("DSFX_CONFIG_DIR")
|
||||
if c.ConfigDir == "" {
|
||||
c.ConfigDir = DefaultConfigDir
|
||||
}
|
||||
|
||||
c.Host = sys.GetEnv("DSFXNODE_HOST")
|
||||
c.StorageDir = sys.GetEnv("DSFX_STORAGE_DIR")
|
||||
if c.StorageDir == "" {
|
||||
c.StorageDir = DefaultStorageDir
|
||||
}
|
||||
|
||||
c.Host = sys.GetEnv("DSFX_HOST")
|
||||
if c.Host == "" {
|
||||
c.Host = DefaultHost
|
||||
}
|
||||
|
||||
c.Port = sys.GetEnv("DSFXNODE_PORT")
|
||||
c.Port = sys.GetEnv("DSFX_PORT")
|
||||
if c.Port == "" {
|
||||
c.Port = DefaultPort
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user