This commit is contained in:
Sense T 2024-04-23 15:23:35 +08:00
parent c7b6a20aad
commit cb86a2b476
7 changed files with 34 additions and 47 deletions

View File

@ -51,7 +51,6 @@ jobs:
id: create_release id: create_release
uses: ncipollo/release-action@v1 uses: ncipollo/release-action@v1
with: with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Release ${{ github.ref }} name: Release ${{ github.ref }}

3
.gitignore vendored
View File

@ -36,4 +36,5 @@ test/
node_modules/ node_modules/
dist/ dist/
.direnv .direnv
result

View File

@ -7,7 +7,7 @@ RUN cd web && npm i && npm run build
FROM golang as server FROM golang as server
WORKDIR /src WORKDIR /src
COPY --from=web /src . COPY --from=web /src .
RUN go get . && go generate ./... && go build . RUN go get . && go generate ./... && go build . -trimpath -ldflags "-w -s -X main.Version=v1.0.0"
FROM scratch FROM scratch
COPY --from=server /src/reCoreD-UI . COPY --from=server /src/reCoreD-UI .

View File

@ -8,7 +8,7 @@
utils.lib.eachDefaultSystem (system: utils.lib.eachDefaultSystem (system:
let let
pkgs = import nixpkgs { inherit system; }; pkgs = import nixpkgs { inherit system; };
name = "recored-ui"; name = "reCoreD-UI";
version = "v1.0.0"; version = "v1.0.0";
in in
{ {
@ -24,10 +24,12 @@
inherit version; inherit version;
src = self; src = self;
GOPROXY = "https://goproxy.cn,direct";
ldflags = [ ldflags = [
"-s" "-s"
"-w" "-w"
"-X main.Version=${version}"
]; ];
configurePhase = '' configurePhase = ''
@ -37,7 +39,8 @@
installPhase = '' installPhase = ''
mkdir -p $out/bin mkdir -p $out/bin
cp recored-ui $out/bin ls -l
cp $HOME/go/bin/reCoreD-UI $out/bin
''; '';
doCheck = false; doCheck = false;
@ -50,7 +53,7 @@
src = self; src = self;
installPhase = '' installPhase = ''
mkdir -p $out/bin mkdir -p $out/bin
cp ${app}/bin/recored-ui $out/bin cp ${app}/bin/reCoreD-UI $out/bin
''; '';
}; };
@ -87,12 +90,12 @@
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
systemd.services.recored-ui = { systemd.services.reCoreD-UI = {
wantedBy = [ "multi-uesr.target" ]; wantedBy = [ "multi-uesr.target" ];
environment = { environment = {
RECORED_MYSQL_DSN = cfg.mysql-dsn; RECORED_MYSQL_DSN = cfg.mysql-dsn;
}; };
serviceconfig.ExecStart = "${defaultPackage}/bin/recored-ui server"; serviceconfig.ExecStart = "${defaultPackage}/bin/reCoreD-UI server";
}; };
}; };
}; };

39
main.go
View File

@ -1,22 +1,25 @@
/* /*
reCoreD-UI provides web ui for CoreDNS reCoreD-UI provides web ui for CoreDNS
NAME: NAME:
reCoreD-UI - Web UI for CoreDNS reCoreD-UI - Web UI for CoreDNS
USAGE: USAGE:
reCoreD-UI [global options] command [command options]
reCoreD-UI [global options] command [command options]
COMMANDS: COMMANDS:
server run server
config config some settings server run server
help, h Shows a list of commands or help for one command config config some settings
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS: GLOBAL OPTIONS:
--config value, -c value config yaml file [$RECORED_CONFIG_FILE]
--mysql-dsn value mysql dsn [$RECORED_MYSQL_DSN] --config value, -c value config yaml file [$RECORED_CONFIG_FILE]
--debug enable debug mode (default: false) --mysql-dsn value mysql dsn [$RECORED_MYSQL_DSN]
--help, -h show help --debug enable debug mode (default: false)
--help, -h show help
*/ */
package main package main
@ -31,15 +34,18 @@ import (
"github.com/urfave/cli/v2/altsrc" "github.com/urfave/cli/v2/altsrc"
) )
// will be modified when building
var Version string = "v0.0.1"
func init() { func init() {
logrus.SetReportCaller(true) logrus.SetReportCaller(true)
} }
// @title reCoreD-UI API // @title reCoreD-UI API
// @version 1.0 // @version 1.0
// @description APIs for reCoreD-UI // @description APIs for reCoreD-UI
// @BasePath /api/v1 // @BasePath /api/v1
// @securityDefinitions.basic BasicAuth // @securityDefinitions.basic BasicAuth
func main() { func main() {
flags := []cli.Flag{ flags := []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{
@ -67,8 +73,9 @@ func main() {
} }
app := &cli.App{ app := &cli.App{
Name: "reCoreD-UI", Name: "reCoreD-UI",
Usage: "Web UI for CoreDNS", Version: Version,
Usage: "Web UI for CoreDNS",
Before: altsrc.InitInputSourceWithContext( Before: altsrc.InitInputSourceWithContext(
flags, altsrc.NewYamlSourceFromFlagFunc("config"), flags, altsrc.NewYamlSourceFromFlagFunc("config"),
), ),

18
package-lock.json generated
View File

@ -1,18 +0,0 @@
{
"name": "recored-ui",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"devDependencies": {
"@vicons/fa": "^0.12.0"
}
},
"node_modules/@vicons/fa": {
"version": "0.12.0",
"resolved": "https://registry.npmmirror.com/@vicons/fa/-/fa-0.12.0.tgz",
"integrity": "sha512-g2PIeJLsTHUjt6bK63LxqC0uYQB7iu+xViJOxvp1s8b9/akpXVPVWjDTTsP980/0KYyMMe4U7F/aUo7wY+MsXA==",
"dev": true
}
}
}

View File

@ -1,5 +0,0 @@
{
"devDependencies": {
"@vicons/fa": "^0.12.0"
}
}