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
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Release ${{ github.ref }}

3
.gitignore vendored
View File

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

View File

@ -7,7 +7,7 @@ RUN cd web && npm i && npm run build
FROM golang as server
WORKDIR /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
COPY --from=server /src/reCoreD-UI .

View File

@ -8,7 +8,7 @@
utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
name = "recored-ui";
name = "reCoreD-UI";
version = "v1.0.0";
in
{
@ -24,10 +24,12 @@
inherit version;
src = self;
GOPROXY = "https://goproxy.cn,direct";
ldflags = [
"-s"
"-w"
"-X main.Version=${version}"
];
configurePhase = ''
@ -37,7 +39,8 @@
installPhase = ''
mkdir -p $out/bin
cp recored-ui $out/bin
ls -l
cp $HOME/go/bin/reCoreD-UI $out/bin
'';
doCheck = false;
@ -50,7 +53,7 @@
src = self;
installPhase = ''
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 {
systemd.services.recored-ui = {
systemd.services.reCoreD-UI = {
wantedBy = [ "multi-uesr.target" ];
environment = {
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
NAME:
reCoreD-UI - Web UI for CoreDNS
USAGE:
reCoreD-UI [global options] command [command options]
reCoreD-UI [global options] command [command options]
COMMANDS:
server run server
config config some settings
help, h Shows a list of commands or help for one command
server run server
config config some settings
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--config value, -c value config yaml file [$RECORED_CONFIG_FILE]
--mysql-dsn value mysql dsn [$RECORED_MYSQL_DSN]
--debug enable debug mode (default: false)
--help, -h show help
--config value, -c value config yaml file [$RECORED_CONFIG_FILE]
--mysql-dsn value mysql dsn [$RECORED_MYSQL_DSN]
--debug enable debug mode (default: false)
--help, -h show help
*/
package main
@ -31,15 +34,18 @@ import (
"github.com/urfave/cli/v2/altsrc"
)
// will be modified when building
var Version string = "v0.0.1"
func init() {
logrus.SetReportCaller(true)
}
// @title reCoreD-UI API
// @version 1.0
// @description APIs for reCoreD-UI
// @BasePath /api/v1
// @securityDefinitions.basic BasicAuth
// @title reCoreD-UI API
// @version 1.0
// @description APIs for reCoreD-UI
// @BasePath /api/v1
// @securityDefinitions.basic BasicAuth
func main() {
flags := []cli.Flag{
&cli.StringFlag{
@ -67,8 +73,9 @@ func main() {
}
app := &cli.App{
Name: "reCoreD-UI",
Usage: "Web UI for CoreDNS",
Name: "reCoreD-UI",
Version: Version,
Usage: "Web UI for CoreDNS",
Before: altsrc.InitInputSourceWithContext(
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"
}
}