分离静态文件
This commit is contained in:
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
@@ -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"
|
||||
|
@@ -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"]
|
||||
|
2
Makefile
2
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)
|
||||
|
11
main.go
11
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,
|
||||
|
Reference in New Issue
Block a user