Skip to content
This repository was archived by the owner on Jul 4, 2024. It is now read-only.

Commit a16eddb

Browse files
authored
Merge pull request #3 from xpunch/dev
[feat] support docker
2 parents 40361b7 + 9cc7f84 commit a16eddb

29 files changed

+745
-58
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
docs
2+
frontend

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
# Swagger
1515
docs/
1616

17-
# frontend dist
18-
web/
17+
# config files
18+
config.yaml
19+
config.toml

Dockerfile

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
1-
FROM golang:1.17 as api-builder
1+
FROM golang:1.17 as builder
22

3-
WORKDIR /usr/local/bin
4-
5-
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o dashboard .
6-
7-
FROM node:17 as web-builder
8-
9-
WORKDIR /usr/local/bin
10-
11-
RUN cd frontend && npm install && ng build --output-path web
3+
RUN git clone https://github.com/xpunch/go-micro-dashboard.git /usr/local/micro \
4+
&& cd /usr/local/micro \
5+
&& go install github.com/swaggo/swag/cmd/swag@latest \
6+
&& swag init \
7+
&& CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o dashboard .
128

139
FROM alpine:latest
1410

1511
WORKDIR /usr/local/bin
1612

17-
COPY --from=api-builder /usr/local/bin/dashboard .
18-
19-
COPY --from=web-builder /usr/local/bin/web .
13+
COPY --from=builder /usr/local/micro/dashboard .
2014

2115
EXPOSE 80
2216

23-
CMD [ "/usr/local/bin/dashboard" ]
17+
ENTRYPOINT [ "/usr/local/bin/dashboard" ]

README.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,19 @@ Go micro dashboard is designed to make it as easy as possible for users to work
55
## Features
66

77
- [ ] Logo
8-
- [x] Dashboard
9-
- [x] Services list
8+
- [x] Web UI
9+
- [x] Service discovery
1010
- [ ] Health check
1111
- [ ] Configure service
12-
- [ ] Endpoint request
12+
- [x] Endpoint request
1313
- [ ] Broker messages
1414

15+
## Installation
16+
17+
```
18+
go install github.com/xpunch/go-micro-dashboard@latest
19+
```
20+
1521
## Development
1622

1723
### Server
@@ -24,25 +30,27 @@ swag init
2430
```
2531

2632
#### Config
33+
2734
```
28-
default username: admin
35+
default username: admin
2936
default password: 123456
3037
```
3138

3239
### Web UI
3340

3441
[Document](https://github.com/xpunch/go-micro-dashboard/tree/main/frontend)
3542

36-
## Docker
43+
#### Generate Web Files
3744

3845
```
39-
docker run .
46+
go install github.com/UnnoTed/fileb0x@latest
47+
fileb0x b0x.yaml
4048
```
4149

42-
## Docker Compose
50+
## Docker
4351

4452
```
45-
docker-compose up -d
53+
docker run -d --name "go-micro-dashboard" -p "4000:4000" xpunch/go-micro-dashboard
4654
```
4755

4856
### Community

b0x.yaml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# all folders and files are relative to the path
2+
# where fileb0x was run at!
3+
4+
# default: main
5+
pkg: web
6+
7+
# destination
8+
dest: "./web/"
9+
10+
# gofmt
11+
# type: bool
12+
# default: false
13+
fmt: true
14+
15+
# compress files
16+
# at the moment, only supports gzip
17+
#
18+
# type: object
19+
compression:
20+
# activates the compression
21+
#
22+
# type: bool
23+
# default: false
24+
compress: false
25+
26+
# valid values are:
27+
# -> "NoCompression"
28+
# -> "BestSpeed"
29+
# -> "BestCompression"
30+
# -> "DefaultCompression" or ""
31+
#
32+
# type: string
33+
# default: "DefaultCompression" # when: Compress == true && Method == ""
34+
method: ""
35+
36+
# true = do it yourself (the file is written as gzip compressed file into the memory file system)
37+
# false = decompress files at run time (while writing file into memory file system)
38+
#
39+
# type: bool
40+
# default: false
41+
keep: false
42+
43+
# ---------------
44+
# -- DANGEROUS --
45+
# ---------------
46+
#
47+
# cleans the destination folder (only b0xfiles)
48+
# you should use this when using the spread function
49+
# type: bool
50+
# default: false
51+
clean: true
52+
53+
# default: ab0x.go
54+
output: "ab0x.go"
55+
56+
# [unexporTed] builds non-exporTed functions, variables and types...
57+
# type: bool
58+
# default: false
59+
unexporTed: false
60+
61+
# [spread] means it will make a file to hold all fileb0x data
62+
# and each file into a separaTed .go file
63+
#
64+
# example:
65+
# theres 2 files in the folder assets, they're: hello.json and world.txt
66+
# when spread is activaTed, fileb0x will make a file:
67+
# b0x.go or [output]'s data, assets_hello.json.go and assets_world.txt.go
68+
#
69+
#
70+
# type: bool
71+
# default: false
72+
spread: true
73+
74+
# [lcf] log changed files when spread is active
75+
lcf: true
76+
77+
# type: array of objects
78+
custom:
79+
- files:
80+
- "frontend/dist"
81+
base: "frontend/dist"
82+
exclude:
83+
- "/3rdpartylicenses.txt"

config.yaml

Lines changed: 0 additions & 11 deletions
This file was deleted.

config/config.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ type ServerConfig struct {
1717
Auth AuthConfig
1818
CORS CORSConfig
1919
Swagger SwaggerConfig
20-
Web WebConfig
2120
}
2221

2322
type AuthConfig struct {
@@ -37,10 +36,6 @@ type SwaggerConfig struct {
3736
Base string
3837
}
3938

40-
type WebConfig struct {
41-
Path string
42-
}
43-
4439
func GetConfig() Config {
4540
return *_cfg
4641
}

config/load.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,9 @@ var _cfg *Config = &Config{
2929
TokenExpiration: 24 * time.Hour,
3030
},
3131
Swagger: SwaggerConfig{
32-
Host: "localhost:4000",
32+
Host: "localhost",
3333
Base: "/",
3434
},
35-
Web: WebConfig{
36-
Path: "web",
37-
},
3835
},
3936
}
4037

@@ -43,10 +40,6 @@ func Load() error {
4340
var configor config.Config
4441
var err error
4542
switch strings.ToLower(os.Getenv("CONFIG_TYPE")) {
46-
case "env":
47-
configor, err = config.NewConfig(
48-
config.WithSource(env.NewSource()),
49-
)
5043
case "toml":
5144
filename := "config.toml"
5245
if name := os.Getenv("CONFIG_FILE"); len(name) > 0 {
@@ -56,7 +49,7 @@ func Load() error {
5649
config.WithSource(file.NewSource(file.WithPath(filename))),
5750
config.WithReader(json.NewReader(reader.WithEncoder(toml.NewEncoder()))),
5851
)
59-
default:
52+
case "yaml":
6053
filename := "config.yaml"
6154
if name := os.Getenv("CONFIG_FILE"); len(name) > 0 {
6255
filename = name
@@ -65,6 +58,10 @@ func Load() error {
6558
config.WithSource(file.NewSource(file.WithPath(filename))),
6659
config.WithReader(json.NewReader(reader.WithEncoder(yaml.NewEncoder()))),
6760
)
61+
default:
62+
configor, err = config.NewConfig(
63+
config.WithSource(env.NewSource()),
64+
)
6865
}
6966
if err != nil {
7067
return errors.Wrap(err, "configor.New")

frontend/angular.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"build": {
5353
"builder": "@angular-devkit/build-angular:browser",
5454
"options": {
55-
"outputPath": "../web",
55+
"outputPath": "dist",
5656
"index": "src/index.html",
5757
"main": "src/main.ts",
5858
"polyfills": "src/polyfills.ts",

frontend/src/app/routes/services/list.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<nz-list-item *ngFor="let service of services" nzNoFlex>
1717
<a (click)="gotoServiceDetail(service.name, undefined)">{{ service.name }}</a>
1818
<span *ngFor="let version of service.versions" style="margin-left:8px;">
19-
<nz-tag [nzColor]="'green'"><a (click)="gotoServiceDetail(service.name, version)">{{ version }}</a></nz-tag>
19+
<nz-tag *ngIf="version" [nzColor]="'green'"><a (click)="gotoServiceDetail(service.name, version)">{{ version }}</a></nz-tag>
2020
</span>
2121
</nz-list-item>
2222
<nz-list-empty *ngIf="!services||!services.length"></nz-list-empty>

0 commit comments

Comments
 (0)