From a77942621e62b849465d79f2837754711c280abb Mon Sep 17 00:00:00 2001 From: Gardel Date: Fri, 3 Feb 2023 03:16:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E7=A6=BB=E9=9D=99=E6=80=81=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 4 ++-- Dockerfile | 1 + Makefile | 2 +- main.go | 11 +---------- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e399209..358843e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -45,14 +45,14 @@ jobs: - name: Create ZIP archive if: startsWith(github.ref, 'refs/tags/') run: | - cp -v ./config_example.ini ./build || exit 1 + cp -v ./config_example.ini ./assets ./build/ || exit 1 pushd build || exit 1 ls -1 yggdrasil-* | while read LINE; do PREFIX="${LINE%.*}" SUFFIX="$(echo "$LINE" | grep -osE '\.\w+' || printf '')" cp -v "$LINE" "yggdrasil$SUFFIX" FILE="../$PREFIX.zip" - zip -9v "$FILE" "yggdrasil$SUFFIX" *.ini + zip -9v "$FILE" "yggdrasil$SUFFIX" *.ini assets DGST="$FILE.dgst" openssl dgst -md5 "$FILE" | sed 's/([^)]*)//g' >>"$DGST" openssl dgst -sha1 "$FILE" | sed 's/([^)]*)//g' >>"$DGST" diff --git a/Dockerfile b/Dockerfile index 3362925..bfc57af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,7 @@ COPY "build/yggdrasil-${TARGETOS}-${TARGETARCH}" /app/yggdrasil EXPOSE 8080 VOLUME /app/data +COPY assets /app/data/assets/ WORKDIR /app/data ENTRYPOINT ["/app/yggdrasil"] diff --git a/Makefile b/Makefile index e3d6a10..c52caa7 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ assets: cp -r frontend/dist/. assets/ package:$(BINARY) - tar -zcf $(PACKAGE_NAME) $(BINARY) config_example.ini + tar -zcf $(PACKAGE_NAME) $(BINARY) config_example.ini assets clean: -$(GO_CLEAN) diff --git a/main.go b/main.go index 7432232..21ef815 100644 --- a/main.go +++ b/main.go @@ -22,13 +22,11 @@ import ( "crypto/rand" "crypto/rsa" "crypto/x509" - "embed" "encoding/pem" "errors" "github.com/gin-gonic/gin" "gopkg.in/ini.v1" "gorm.io/gorm" - "io/fs" "log" "net/http" "os" @@ -40,9 +38,6 @@ import ( "yggdrasil-go/util" ) -//go:embed assets/* -var f embed.FS - type MetaCfg struct { ServerName string `ini:"server_name"` ImplementationName string `ini:"implementation_name"` @@ -139,11 +134,7 @@ func main() { log.Fatal(err) } router.InitRouters(r, db, &serverMeta, meta.SkinRootUrl) - assetsFs, err := fs.Sub(f, "assets") - if err != nil { - log.Fatal(err) - } - r.StaticFS("/profile", http.FS(assetsFs)) + r.Static("/profile", "assets") srv := &http.Server{ Addr: serverCfg.ServerAddress, Handler: r,