merge from dev, ci-done
This commit is contained in:
parent
021ec9c8f6
commit
7ec564aac0
78
.github/workflows/docker-publish.yml
vendored
Normal file
78
.github/workflows/docker-publish.yml
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
name: Docker
|
||||
|
||||
# This workflow uses actions that are not certified by GitHub.
|
||||
# They are provided by a third-party and are governed by
|
||||
# separate terms of service, privacy policy, and support
|
||||
# documentation.
|
||||
|
||||
on:
|
||||
push:
|
||||
# Publish semver tags as releases.
|
||||
tags: [ 'v*.*.*' ]
|
||||
|
||||
|
||||
env:
|
||||
# Use docker.io for Docker Hub if empty
|
||||
REGISTRY: ghcr.io
|
||||
# github.repository as <account>/<repo>
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
# This is used to complete the identity challenge
|
||||
# with sigstore/fulcio when running outside of PRs.
|
||||
id-token: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# Install the cosign tool except on PR
|
||||
# https://github.com/sigstore/cosign-installer
|
||||
- name: Install cosign
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: sigstore/cosign-installer@v3.3.0
|
||||
with:
|
||||
cosign-release: v1.13.2
|
||||
|
||||
|
||||
# Workaround: https://github.com/docker/build-push-action/issues/461
|
||||
- name: Setup Docker buildx
|
||||
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
|
||||
|
||||
# Login against a Docker registry except on PR
|
||||
# https://github.com/docker/login-action
|
||||
- name: Log into registry ${{ env.REGISTRY }}
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# Extract metadata (tags, labels) for Docker
|
||||
# https://github.com/docker/metadata-action
|
||||
- name: Extract Docker metadata
|
||||
id: meta
|
||||
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
|
||||
# Build and push Docker image with Buildx (don't push on PR)
|
||||
# https://github.com/docker/build-push-action
|
||||
- name: Build and push Docker image
|
||||
id: build-and-push
|
||||
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
|
||||
with:
|
||||
context: .
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
|
77
.github/workflows/go.yml
vendored
Normal file
77
.github/workflows/go.yml
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
name: Go
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*.*.*'
|
||||
|
||||
jobs:
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up NodeJS
|
||||
uses: actions/setup-node@v4
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: 1.22
|
||||
|
||||
- name: Build Web UI
|
||||
run: |
|
||||
cd web
|
||||
npm i && npm run build
|
||||
cd ..
|
||||
go generate ./...
|
||||
|
||||
- name: Build-linux-amd64
|
||||
env:
|
||||
GOOS: linux
|
||||
GOARCH: amd64
|
||||
run: |
|
||||
mkdir -p recored-ui-${GOOS}-${GOARCH}
|
||||
go build -trimpath -ldflags "-w -s" -v -o ./recored-ui-${GOOS}-${GOARCH} ./...
|
||||
cp README.md LICENSE recored-ui-${GOOS}-${GOARCH}
|
||||
tar czvf recored-ui-${GOOS}-${GOARCH}.tgz recored-ui-${GOOS}-${GOARCH}
|
||||
|
||||
- name: Build-linux-arm64
|
||||
env:
|
||||
GOOS: linux
|
||||
GOARCH: arm64
|
||||
run: |
|
||||
mkdir -p recored-ui-${GOOS}-${GOARCH}
|
||||
go build -trimpath -ldflags "-w -s -X main.Version=${{ github.ref_name }}" -v -o ./recored-ui-${GOOS}-${GOARCH} ./...
|
||||
cp README.md LICENSE recored-ui-${GOOS}-${GOARCH}
|
||||
tar czvf recored-ui-${GOOS}-${GOARCH}.tgz recored-ui-${GOOS}-${GOARCH}
|
||||
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: ncipollo/release-action@v1
|
||||
with:
|
||||
name: Release ${{ github.ref_name }}
|
||||
|
||||
|
||||
- name: Upload Release Asset Linux arm64
|
||||
id: upload-release-asset-linux-arm
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: ${{ github.workspace }}/recored-ui-linux-arm64.tgz
|
||||
asset_name: recored-ui-linux-arm64.tgz
|
||||
asset_content_type: application/x-gzip
|
||||
|
||||
- name: Upload Release Asset Linux amd64
|
||||
id: upload-release-asset-linux-amd64
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: ${{ github.workspace }}/recored-ui-linux-amd64.tgz
|
||||
asset_name: recored-ui-linux-amd64.tgz
|
||||
asset_content_type: application/x-gzip
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -16,7 +16,8 @@
|
||||
*.out
|
||||
|
||||
# Dependency directories (remove the comment below to include it)
|
||||
# vendor/
|
||||
!vendor/modules.txt
|
||||
vendor/**/*
|
||||
|
||||
# Go workspace file
|
||||
go.work
|
||||
@ -36,3 +37,4 @@ node_modules/
|
||||
dist/
|
||||
|
||||
.direnv
|
||||
result
|
||||
|
@ -6,9 +6,9 @@ RUN cd web && npm i && npm run build
|
||||
|
||||
FROM golang as server
|
||||
WORKDIR /src
|
||||
COPY --stage web /src .
|
||||
RUN go get . && go generate ./... && go build .
|
||||
COPY --from=web /src .
|
||||
RUN go get . && go generate ./... && go build -trimpath -ldflags '-w -s -X main.Version=v1.0.0' .
|
||||
|
||||
FROM scratch
|
||||
COPY --stage server /src/reCoreD-UI .
|
||||
COPY --from=server /src/reCoreD-UI .
|
||||
ENTRYPOINT [ '/reCoreD-UI' ]
|
||||
|
52
flake.nix
52
flake.nix
@ -8,26 +8,52 @@
|
||||
utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
name = "reCoreD-UI";
|
||||
version = "v1.0.0";
|
||||
in
|
||||
{
|
||||
packages = rec {
|
||||
recored-ui = with pkgs; stdenv.mkDerivation rec {
|
||||
name = "recored-ui";
|
||||
defaultPackage = with pkgs; let
|
||||
web = buildNpmPackage {
|
||||
inherit version;
|
||||
pname = name;
|
||||
src = "${self}/web";
|
||||
npmDepsHash = "sha256-e4AYJa0PXhuBRytH4860v6t3DEcQ5awR24HeXRD5pew=";
|
||||
};
|
||||
app = buildGoModule {
|
||||
pname = name;
|
||||
inherit version;
|
||||
|
||||
src = self;
|
||||
buildInputs = [
|
||||
go
|
||||
nodejs
|
||||
|
||||
ldflags = [
|
||||
"-s"
|
||||
"-w"
|
||||
"-X main.Version=${version}"
|
||||
];
|
||||
buildPhase = ''
|
||||
cd web && npm i && npm run build && cd ..
|
||||
go get . && go generate ./... && go build . -o recored-ui -ldflags "-s -w"
|
||||
|
||||
configurePhase = ''
|
||||
cp -r ${web}/lib/node_modules/web/dist server
|
||||
export HOME=/tmp/build
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp recored-ui $out/bin
|
||||
ls -l
|
||||
cp $HOME/go/bin/reCoreD-UI $out/bin
|
||||
'';
|
||||
|
||||
doCheck = false;
|
||||
deleteVendor = true;
|
||||
proxyVendor = true;
|
||||
};
|
||||
default = recored-ui;
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
name = "${name}-${version}";
|
||||
src = self;
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp ${app}/bin/reCoreD-UI $out/bin
|
||||
'';
|
||||
};
|
||||
|
||||
devShell = with pkgs; mkShell {
|
||||
@ -63,12 +89,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 = "${pkgs.recored-ui}/bin/recored-ui server";
|
||||
serviceconfig.ExecStart = "${defaultPackage}/bin/reCoreD-UI server";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
41
main.go
41
main.go
@ -1,3 +1,26 @@
|
||||
/*
|
||||
reCoreD-UI provides web ui for CoreDNS
|
||||
|
||||
NAME:
|
||||
reCoreD-UI - Web UI for CoreDNS
|
||||
|
||||
USAGE:
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
*/
|
||||
package main
|
||||
|
||||
import (
|
||||
@ -11,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{
|
||||
@ -47,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,6 +18,7 @@ type Props = {
|
||||
createRecord(record: Record): Promise<void>
|
||||
}
|
||||
|
||||
// convert enum RecordTypes to a list for select options.
|
||||
const recordTypeOptions = Object.entries(RecordTypes).filter(e => e[1] !== RecordTypes.RecordTypeSOA).map(e => {
|
||||
return {
|
||||
value: e[1],
|
||||
@ -246,6 +247,8 @@ export default function RecordEditModal({ open, record, onOk, onCancel, editReco
|
||||
</Form.Item>
|
||||
<Form.Item<Record> noStyle shouldUpdate={(p, c) => p.record_type !== c.record_type}>
|
||||
{
|
||||
// load form for record type from the map 'controls'.
|
||||
// this is a dynamic form
|
||||
({ getFieldValue }: FormInstance<Record>) => {
|
||||
const e = controls.get(getFieldValue('record_type'))
|
||||
if (!e) {
|
||||
|
@ -1,3 +1,8 @@
|
||||
/*
|
||||
Web UI for reCoreD-UI
|
||||
Use React and ant-design now.
|
||||
JSX/TSX is cool!
|
||||
*/
|
||||
import React from 'react'
|
||||
import ReactDOM from 'react-dom/client'
|
||||
import App from './App.tsx'
|
||||
|
Loading…
Reference in New Issue
Block a user