mirror of
https://github.com/trafficlunar/statsys.git
synced 2026-03-28 11:13:17 +00:00
feat: docker and flags support
This commit is contained in:
parent
b1deb5929a
commit
5a07e249ac
9 changed files with 113 additions and 9 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1 +1 @@
|
|||
*.db
|
||||
data/
|
||||
21
Dockerfile
Normal file
21
Dockerfile
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# build
|
||||
FROM golang:1.25.4 AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN CGO_ENABLED=0 go build -o statsys .
|
||||
|
||||
# copy
|
||||
FROM alpine:latest
|
||||
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app/statsys .
|
||||
COPY --from=builder /app/www /app/www
|
||||
|
||||
EXPOSE 8888/tcp
|
||||
CMD [ "/app/statsys", "-config", "data/config.toml", "-db", "data/status.db" ]
|
||||
75
README.md
75
README.md
|
|
@ -1,6 +1,77 @@
|
|||
<h1 align="center">statsys</h1>
|
||||
|
||||
TODO: thumbnail
|
||||

|
||||
|
||||
<p align="center">The cutest lightweight status page</p>
|
||||
<p align="center">the cutest lightweight status page</p>
|
||||
<h4 align="center"><a href="https://status.trafficlunar.net">view demo</a> | <a href="#install">install</a></h4>
|
||||
|
||||
## install
|
||||
|
||||
<details>
|
||||
<summary><strong>docker compose (recommended)</strong></summary>
|
||||
<br>
|
||||
|
||||
Create a `docker-compose.yaml` file:
|
||||
|
||||
```yaml
|
||||
services:
|
||||
statsys:
|
||||
container_name: statsys
|
||||
image: trafficlunar/statsys
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./data/:/app/data/
|
||||
ports:
|
||||
- 8888:8888
|
||||
```
|
||||
|
||||
Create a new directory called `data` and download the `config.toml` example and edit it:
|
||||
|
||||
```bash
|
||||
mkdir data && cd data
|
||||
wget https://raw.githubusercontent.com/trafficlunar/statsys/refs/heads/main/config.toml
|
||||
```
|
||||
|
||||
When ready, run:
|
||||
|
||||
```bash
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
Navigate to `localhost:8888` to view your status page!
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><strong>docker quick run</strong></summary>
|
||||
<br>
|
||||
|
||||
Create a new directory called `data` and download the `config.toml` example and edit it:
|
||||
|
||||
```bash
|
||||
mkdir data && cd data
|
||||
wget https://raw.githubusercontent.com/trafficlunar/statsys/refs/heads/main/config.toml
|
||||
```
|
||||
|
||||
Launch the container:
|
||||
|
||||
```bash
|
||||
docker run -d \
|
||||
--name statsys \
|
||||
--restart unless-stopped \
|
||||
-v "$(pwd)/data:/app/data" \
|
||||
-p 8888:8888 \
|
||||
trafficlunar/statsys
|
||||
```
|
||||
|
||||
Navigate to `localhost:8888` to view your status page!
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><strong>manual</strong></summary>
|
||||
<br>
|
||||
|
||||
TODO
|
||||
|
||||
</details>
|
||||
|
|
|
|||
1
TODO.md
1
TODO.md
|
|
@ -1,5 +1,4 @@
|
|||
- [ ] Accessibility
|
||||
- [ ] Better mobile support
|
||||
- [ ] View incidents
|
||||
- [ ] Latency graphs?
|
||||
- [ ] README
|
||||
|
|
|
|||
BIN
assets/thumbnail.png
Normal file
BIN
assets/thumbnail.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 55 KiB |
|
|
@ -26,7 +26,7 @@ type Config struct {
|
|||
var config Config
|
||||
|
||||
func LoadConfig() {
|
||||
configFile, err := os.ReadFile("config.toml")
|
||||
configFile, err := os.ReadFile(*ConfigPath)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to load config: %v", err)
|
||||
}
|
||||
|
|
@ -60,5 +60,5 @@ func LoadConfig() {
|
|||
templateData.Services[index] = service
|
||||
}
|
||||
|
||||
log.Println("config loaded")
|
||||
log.Printf("config loaded from '%s'", *ConfigPath)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ var db *sql.DB
|
|||
func InitDatabase() {
|
||||
// open/create database
|
||||
var err error
|
||||
db, err = sql.Open("sqlite", "status.db")
|
||||
db, err = sql.Open("sqlite", *DatabasePath)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to initalise database: %v", err)
|
||||
log.Fatalf("failed to initalize database: %v", err)
|
||||
}
|
||||
|
||||
db.SetMaxOpenConns(1)
|
||||
|
|
@ -97,7 +97,7 @@ func InitDatabase() {
|
|||
templateData.Services[index] = service
|
||||
}
|
||||
|
||||
log.Println("database initalised")
|
||||
log.Printf("database initalized at '%s'", *DatabasePath)
|
||||
}
|
||||
|
||||
func CloseDatabase() {
|
||||
|
|
|
|||
12
internal/flags.go
Normal file
12
internal/flags.go
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
package internal
|
||||
|
||||
import "flag"
|
||||
|
||||
var ConfigPath *string
|
||||
var DatabasePath *string
|
||||
|
||||
func ParseFlags() {
|
||||
ConfigPath = flag.String("config", "config.toml", "path to config file")
|
||||
DatabasePath = flag.String("db", "status.db", "path to database file")
|
||||
flag.Parse()
|
||||
}
|
||||
1
main.go
1
main.go
|
|
@ -3,6 +3,7 @@ package main
|
|||
import "statsys/internal"
|
||||
|
||||
func main() {
|
||||
internal.ParseFlags()
|
||||
internal.LoadConfig()
|
||||
internal.InitDatabase()
|
||||
defer internal.CloseDatabase()
|
||||
|
|
|
|||
Loading…
Reference in a new issue