From 80304937e1936a9378f13129e15fed1d7c8e2668 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=B0=8F=E7=99=BD?= <296015668@qq.com> Date: Thu, 15 Jun 2023 11:19:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=8D=E4=BD=BF=E7=94=A8=20cgo=20(#1?= =?UTF-8?q?382)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-test.yml | 6 ++--- .github/workflows/release-drafter.yml | 28 ++++++++++++++++------ .gitignore | 1 + .goreleaser.yaml | 9 ------- Dockerfile | 34 --------------------------- backend/init/db/db.go | 5 ++-- cmd/server/cmd/root.go | 2 +- go.mod | 9 ++++++- go.sum | 20 ++++++++++++++-- 9 files changed, 54 insertions(+), 60 deletions(-) delete mode 100644 Dockerfile diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 225499401..613374023 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -12,9 +12,7 @@ jobs: build-linux-binary: runs-on: ubuntu-latest steps: - - name: Install cross-compilers - run: sudo apt-get update && sudo apt-get -y install gcc-x86-64-linux-gnu gcc-aarch64-linux-gnu gcc-arm-linux-gnueabi gcc-powerpc64le-linux-gnu gcc-s390x-linux-gnu - - name: Checkout code + - name: Checkout Code uses: actions/checkout@v3 - name: Setup Node uses: actions/setup-node@v3 @@ -23,7 +21,7 @@ jobs: - name: Build Web id: build_frontend run: | - cd frontend && npm install && npm run build:dev + cd frontend && npm install && npm run build:pro env: NODE_OPTIONS: --max-old-space-size=8192 - name: Setup Go diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 46504a446..b366eed77 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -10,9 +10,7 @@ jobs: create-release: runs-on: ubuntu-latest steps: - - name: Install cross-compilers - run: sudo apt-get update && sudo apt-get -y install gcc-x86-64-linux-gnu gcc-aarch64-linux-gnu gcc-arm-linux-gnueabi gcc-powerpc64le-linux-gnu gcc-s390x-linux-gnu - - name: Checkout code + - name: Checkout Code uses: actions/checkout@v2 - name: Setup Node uses: actions/setup-node@v3 @@ -20,7 +18,7 @@ jobs: node-version: '18.14' - name: Build Web run: | - cd frontend && npm install && npm run build:dev + cd frontend && npm install && npm run build:pro env: NODE_OPTIONS: --max-old-space-size=8192 - name: Setup Go @@ -30,17 +28,33 @@ jobs: - name: Build Release uses: goreleaser/goreleaser-action@v4 with: + distribution: goreleaser + version: latest args: release --skip-publish --clean - name: Upload Assets uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') with: draft: true + body: | + # 一、安装和升级 + + ## 1.1 一键安装 + ```sh + curl -sSL https://resource.fit2cloud.com/1panel/package/quick_start.sh -o quick_start.sh && sudo bash quick_start.sh + ``` + + ## 1.2 在线升级 + + 登录 1Panel Web 控制台,在页面右下角点击 **【检查更新】** 进行在线升级。 + + >更多信息请查阅在线文档:https://1panel.cn/docs/ + + # 二、更新日志 + files: | dist/*.tar.gz dist/checksums.txt - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Setup OSSUTIL uses: yizhoumo/setup-ossutil@v1 with: @@ -49,4 +63,4 @@ jobs: access-key-secret: ${{ secrets.OSS_ACCESS_KEY_SECRET }} ossutil-version: '1.7.14' - name: Upload Assets to OSS - run: ossutil cp -r dist/ oss://resource-fit2cloud-com/1panel/package/stable/${{ github.ref_name }}/release/ --include "*.tar.gz" --include "checksums.txt" --only-current-dir \ No newline at end of file + run: ossutil cp -r dist/ oss://resource-fit2cloud-com/1panel/package/stable/${{ github.ref_name }}/release/ --include "*.tar.gz" --include "checksums.txt" --only-current-dir --force \ No newline at end of file diff --git a/.gitignore b/.gitignore index b9a7690b9..4af6f7b6b 100644 --- a/.gitignore +++ b/.gitignore @@ -30,5 +30,6 @@ dist/ 1pctl 1panel.service install.sh +quick_start.sh cmd/server/web/.DS_Store cmd/server/.DS_Store diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 0ffbf7aaa..bc7a93342 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -19,15 +19,6 @@ builds: - --extldflags "-static -fpic" tags: - osusergo - env: - - CGO_ENABLED=1 - - >- - {{- if eq .Arch "amd64"}}CC=x86_64-linux-gnu-gcc{{- end }} - {{- if eq .Arch "arm64"}}CC=aarch64-linux-gnu-gcc{{- end }} - {{- if eq .Arch "arm"}}CC=arm-linux-gnueabi-gcc{{- end }} - {{- if eq .Arch "loong64"}}CC=loongarch64-linux-gnu-gcc{{- end }} - {{- if eq .Arch "ppc64le"}}CC=powerpc64le-linux-gnu-gcc{{- end }} - {{- if eq .Arch "s390x"}}CC=s390x-linux-gnu-gcc{{- end }} goos: - linux goarm: diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index af22c4dca..000000000 --- a/Dockerfile +++ /dev/null @@ -1,34 +0,0 @@ -FROM node:18.14 as build_web -ARG TARGETARCH -ARG NPM_REGISTRY="https://registry.npmmirror.com" -ENV NODE_OPTIONS="--max-old-space-size=4096" - -WORKDIR /data - -RUN set -ex \ - && npm config set registry ${NPM_REGISTRY} - -ADD . /data - -RUN set -ex \ - && cd /data/frontend \ - && npm install - -RUN set -ex \ - && cd /data/frontend \ - && npm run build:dev - -FROM golang:1.20 -ARG TARGETARCH -ARG GOPROXY="https://goproxy.cn,direct" - -COPY --from=build_web /data /data - -WORKDIR /data - -RUN set -ex \ - && go env -w GOPROXY=${GOPROXY} \ - && go install github.com/goreleaser/goreleaser@latest \ - && goreleaser build --single-target --snapshot --clean - -CMD ["/bin/bash"] \ No newline at end of file diff --git a/backend/init/db/db.go b/backend/init/db/db.go index 4f081c37f..e549b4595 100644 --- a/backend/init/db/db.go +++ b/backend/init/db/db.go @@ -2,12 +2,13 @@ package db import ( "fmt" - "gorm.io/gorm/logger" "log" "os" "time" - "gorm.io/driver/sqlite" + "gorm.io/gorm/logger" + + "github.com/glebarez/sqlite" "gorm.io/gorm" "github.com/1Panel-dev/1Panel/backend/global" diff --git a/cmd/server/cmd/root.go b/cmd/server/cmd/root.go index 4657eb920..de765c70b 100644 --- a/cmd/server/cmd/root.go +++ b/cmd/server/cmd/root.go @@ -7,8 +7,8 @@ import ( "github.com/1Panel-dev/1Panel/backend/server" cmdUtils "github.com/1Panel-dev/1Panel/backend/utils/cmd" + "github.com/glebarez/sqlite" "github.com/spf13/cobra" - "gorm.io/driver/sqlite" "gorm.io/gorm" ) diff --git a/go.mod b/go.mod index 6ed661ed2..5fad1d70e 100644 --- a/go.mod +++ b/go.mod @@ -17,6 +17,7 @@ require ( github.com/gin-contrib/gzip v0.0.6 github.com/gin-contrib/i18n v0.0.1 github.com/gin-gonic/gin v1.9.1 + github.com/glebarez/sqlite v1.8.0 github.com/go-acme/lego/v4 v4.9.0 github.com/go-gormigrate/gormigrate/v2 v2.0.2 github.com/go-playground/validator/v10 v10.14.0 @@ -56,7 +57,7 @@ require ( gopkg.in/square/go-jose.v2 v2.6.0 gopkg.in/yaml.v3 v3.0.1 gorm.io/driver/sqlite v1.4.4 - gorm.io/gorm v1.24.5 + gorm.io/gorm v1.24.6 ) require ( @@ -112,6 +113,7 @@ require ( github.com/fvbommel/sortorder v1.0.2 // indirect github.com/gabriel-vasile/mimetype v1.4.2 // indirect github.com/gin-contrib/sse v0.1.0 // indirect + github.com/glebarez/go-sqlite v1.21.1 // indirect github.com/go-logr/logr v1.2.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.2.6 // indirect @@ -200,6 +202,7 @@ require ( github.com/prometheus/client_model v0.3.0 // indirect github.com/prometheus/common v0.37.0 // indirect github.com/prometheus/procfs v0.8.0 // indirect + github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/rivo/uniseg v0.2.0 // indirect github.com/rs/xid v1.4.0 // indirect github.com/serialx/hashring v0.0.0-20190422032157-8b2912629002 // indirect @@ -258,6 +261,10 @@ require ( k8s.io/client-go v0.24.1 // indirect k8s.io/klog/v2 v2.80.1 // indirect k8s.io/utils v0.0.0-20221107191617-1a15be271d1d // indirect + modernc.org/libc v1.22.3 // indirect + modernc.org/mathutil v1.5.0 // indirect + modernc.org/memory v1.5.0 // indirect + modernc.org/sqlite v1.21.1 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect sigs.k8s.io/yaml v1.3.0 // indirect ) diff --git a/go.sum b/go.sum index a53ab30d1..50922a3ff 100644 --- a/go.sum +++ b/go.sum @@ -276,6 +276,10 @@ github.com/gin-gonic/gin v1.7.4/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjX github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= +github.com/glebarez/go-sqlite v1.21.1 h1:7MZyUPh2XTrHS7xNEHQbrhfMZuPSzhkm2A1qgg0y5NY= +github.com/glebarez/go-sqlite v1.21.1/go.mod h1:ISs8MF6yk5cL4n/43rSOmVMGJJjHYr7L2MbZZ5Q4E2E= +github.com/glebarez/sqlite v1.8.0 h1:02X12E2I/4C1n+v90yTqrjRa8yuo7c3KeHI3FRznCvc= +github.com/glebarez/sqlite v1.8.0/go.mod h1:bpET16h1za2KOOMb8+jCp6UBP/iahDpfPQqSaYLTLx8= github.com/go-acme/lego/v4 v4.9.0 h1:8Hjj44IqRS7cigshMyFQ+0pIZvwgkG/+9A0UnNh7G8A= github.com/go-acme/lego/v4 v4.9.0/go.mod h1:g3JRUyWS3L/VObpp4bCxzJftKyf/Wba8QrSSnoiqjg4= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= @@ -431,6 +435,7 @@ github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 h1:Xim43kblpZXfIBQsbuBVKCudVG457BR2GZFIz3uw3hQ= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= @@ -748,6 +753,9 @@ github.com/qiniu/dyn v1.3.0/go.mod h1:E8oERcm8TtwJiZvkQPbcAh0RL8jO1G0VXJMW3FAWdk github.com/qiniu/go-sdk/v7 v7.14.0 h1:6icihMTKHoKMmeU1mqtIoHUv7c1LrLjYm8wTQaYDqmw= github.com/qiniu/go-sdk/v7 v7.14.0/go.mod h1:btsaOc8CA3hdVloULfFdDgDc+g4f3TDZEFsDY0BLE+w= github.com/qiniu/x v1.10.5/go.mod h1:03Ni9tj+N2h2aKnAz+6N0Xfl8FwMEDRC2PAlxekASDs= +github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= +github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= +github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= @@ -1343,8 +1351,8 @@ gorm.io/driver/sqlite v1.4.4 h1:gIufGoR0dQzjkyqDyYSCvsYR6fba1Gw5YKDqKeChxFc= gorm.io/driver/sqlite v1.4.4/go.mod h1:0Aq3iPO+v9ZKbcdiz8gLWRw5VOPcBOPUQJFLq5e2ecI= gorm.io/driver/sqlserver v1.3.2 h1:yYt8f/xdAKLY7lCCyXxIUEgZ/WsURos3dHrx8MKFGAk= gorm.io/gorm v1.24.0/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA= -gorm.io/gorm v1.24.5 h1:g6OPREKqqlWq4kh/3MCQbZKImeB9e6Xgc4zD+JgNZGE= -gorm.io/gorm v1.24.5/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA= +gorm.io/gorm v1.24.6 h1:wy98aq9oFEetsc4CAbKD2SoBCdMzsbSIvSUUFJuHi5s= +gorm.io/gorm v1.24.6/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k= gotest.tools/v3 v3.4.0 h1:ZazjZUfuVeZGLAmlKKuyv3IKP5orXcwtOwDQH6YVr6o= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= @@ -1368,6 +1376,14 @@ k8s.io/kube-openapi v0.0.0-20211109043538-20434351676c/go.mod h1:vHXdDvt9+2spS2R k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= k8s.io/utils v0.0.0-20221107191617-1a15be271d1d h1:0Smp/HP1OH4Rvhe+4B8nWGERtlqAGSftbSbbmm45oFs= k8s.io/utils v0.0.0-20221107191617-1a15be271d1d/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +modernc.org/libc v1.22.3 h1:D/g6O5ftAfavceqlLOFwaZuA5KYafKwmr30A6iSqoyY= +modernc.org/libc v1.22.3/go.mod h1:MQrloYP209xa2zHome2a8HLiLm6k0UT8CoHpV74tOFw= +modernc.org/mathutil v1.5.0 h1:rV0Ko/6SfM+8G+yKiyI830l3Wuz1zRutdslNoQ0kfiQ= +modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= +modernc.org/memory v1.5.0 h1:N+/8c5rE6EqugZwHii4IFsaJ7MUhoWX07J5tC/iI5Ds= +modernc.org/memory v1.5.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU= +modernc.org/sqlite v1.21.1 h1:GyDFqNnESLOhwwDRaHGdp2jKLDzpyT/rNLglX3ZkMSU= +modernc.org/sqlite v1.21.1/go.mod h1:XwQ0wZPIh1iKb5mkvCJ3szzbhk+tykC8ZWqTRTgYRwI= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=