Skip to content

Commit 6fa73d4

Browse files
committed
Added multiarch docker tags
1 parent 1b2ceb4 commit 6fa73d4

10 files changed

Lines changed: 27 additions & 37 deletions

File tree

.DS_Store

0 Bytes
Binary file not shown.

Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ RUN apk add sqlite yarn gcc libc-dev
77
COPY . .
88

99
RUN cd web && yarn install && NODE_ENV=production yarn build
10-
RUN cd server && go run scripts/initdb.go
1110
RUN cd server && go build -o astroserver.sh cmd/astro/main.go
1211

1312
######################################################

Makefile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,12 @@
33
compile-server:
44
@cd server && go build -o astroserver.sh cmd/server/main.go
55

6-
compile-initdb:
7-
@cd server && go build -o initdb.sh pkg/script/initdb.go
8-
96
build-docker:
107
@docker build -t igorsheg/astrodash:latest .
118

129
init-db:
1310
@sqlite3 ./server/data/astrodb.db "VACUUM;"
1411

15-
seed-db:
16-
@cd server && go run scripts/initdb.go
17-
1812
clean:
1913
@cd server && rm -rf data/*
2014

README.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ To launch container:
1717
```sh
1818
docker run -d \
1919
-p 8088:8088 \
20-
-v </your/local/path/>:/server/data \
20+
-v </your/local/path/>:/app/server/data \
2121
igorsheg/astro
2222
```
2323

@@ -36,13 +36,6 @@ cd astro
3636
make install-dep
3737
```
3838

39-
3. Init Database
40-
41-
```sh
42-
make init-db
43-
make seed-db
44-
```
45-
4639
4. Run Backend
4740

4841
```sh
File renamed without changes.

server/cmd/astro/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ func main() {
2020

2121
ginEngine := gin.Default()
2222

23-
db, err := gorm.Open(sqlite.Open("./data/astrodb.db"), &gorm.Config{})
23+
db, err := gorm.Open(sqlite.Open("data/astrodb.db"), &gorm.Config{})
2424
if err != nil {
2525
panic("failed to connect database")
2626
}
2727

28+
handlers.InitDb(db)
2829
handlers.SetupRoutes(ginEngine, db)
2930

3031
ginEngine.Run(os.Getenv("HTTP_ADDRESS") + ":" + os.Getenv("HTTP_PORT"))

server/pkg/config/config.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import (
66
)
77

88
type Config struct {
9-
ID string `json:"id"`
10-
Title string `json:"title"`
11-
Subtitle string `json:"subtitle"`
9+
ID string `json:"id"`
10+
Title string `json:"title"`
11+
Subtitle string `json:"subtitle"`
12+
FirstTimer string `json:"fisrtTimer"`
1213
}
1314

1415
func NewService(ctx *gin.Engine, db *gorm.DB) Config {
Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package handlers
22

33
import (
44
"astro/pkg/category"
@@ -11,24 +11,31 @@ import (
1111
"github.com/google/uuid"
1212
"github.com/mbndr/figlet4go"
1313
"gorm.io/datatypes"
14-
"gorm.io/driver/sqlite"
1514
"gorm.io/gorm"
1615
)
1716

18-
func main() {
17+
func tableExists(db *gorm.DB) bool {
18+
19+
return db.Migrator().HasTable(&config.Config{}) &&
20+
db.Migrator().HasTable(&service.Service{}) &&
21+
db.Migrator().HasTable(&category.Category{}) &&
22+
db.Migrator().HasTable(&theme.Theme{})
23+
}
24+
25+
func InitDb(db *gorm.DB) {
1926

2027
ascii := figlet4go.NewAsciiRender()
2128
options := figlet4go.NewRenderOptions()
2229
options.FontName = "larry3d"
2330
renderStr, _ := ascii.RenderOpts("Astro", options)
2431
fmt.Print(renderStr)
2532

26-
color.Green("---> Initiating Data")
27-
28-
db, err := gorm.Open(sqlite.Open("./data/astrodb.db"), &gorm.Config{})
29-
if err != nil {
30-
panic("failed to connect database")
33+
if tableExists(db) {
34+
color.Green("---> Using existing databse")
35+
return
3136
}
37+
38+
color.Green("---> Initiating Data")
3239
color.Green("---> Migrating Entities")
3340
db.AutoMigrate(&service.Service{}, &category.Category{}, &theme.Theme{}, &config.Config{}, &service.Ping{})
3441

web/.DS_Store

0 Bytes
Binary file not shown.

web/package.json

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
{
2-
"name": "react-esbuild-starter",
3-
"version": "2.1.0",
4-
"description": "Starter template for React + Typescript, powered by Esbuild",
5-
"repository": "https://github.com/belaczek/react-esbuild-starter.git",
6-
"author": "Tomas Belada <tomas@belada.net>",
2+
"name": "astro",
3+
"version": "0.5.0",
4+
"description": "An open, extensible, dashboard for all of your homelab services.",
5+
"repository": "https://github.com/igorsheg/astro.git",
6+
"author": "Igor Shegolev <igorsheg@gmail.com>",
77
"license": "MIT",
8-
"keywords": [
9-
"react",
10-
"typescript",
11-
"esbuild"
12-
],
138
"scripts": {
149
"start": "yarn run concurrently --names tsc,esb -c green.bold,blue.bold --kill-others \"yarn:bundle --dev\" \"tsc --watch\" ",
1510
"build": "yarn run concurrently --success --names tsc,esb -c green.bold,blue.bold tsc yarn:bundle",

0 commit comments

Comments
 (0)