mirror of
https://github.com/Damillora/phoebe.git
synced 2025-04-15 19:33:12 +00:00
Compare commits
6 Commits
59f796331a
...
fa81548e8a
Author | SHA1 | Date | |
---|---|---|---|
fa81548e8a | |||
69abeb93cb | |||
6b0c47bcdb | |||
724b857c99 | |||
f62e3d3b7c | |||
51453a8e93 |
.github/workflows
Dockerfilepkg
app
web
.eslintignore.eslintrc.cjs.gitignore.npmrcREADME.mdembed.gopackage-lock.jsonpackage.json
src
app.d.tsapp.htmlapp.scss
lib
api.tsindex.tslogin-check.jssimple-pagination.jsstores.ts
components
checks
panels
EditPostPanel.svelteEditTagNotesPanel.svelteEditTagPanel.svelteUserActionsPanel.svelteViewPostPanel.svelteViewTagNotesPanel.svelteViewTagPanel.svelte
ui
routes
static
svelte.config.jstsconfig.jsonvite.config.tsweb
60
.github/workflows/workflow.yml
vendored
60
.github/workflows/workflow.yml
vendored
@ -3,30 +3,72 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- "v*"
|
||||
env:
|
||||
IS_RELEASE: ${{ startsWith(github.ref, 'refs/tags/') && 'true' || 'false' }}
|
||||
jobs:
|
||||
release:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
platform: [linux/amd64,linux/arm64]
|
||||
env:
|
||||
IS_LINUX: ${{ startsWith(matrix.platform, 'linux/') && 'true' || 'false' }}
|
||||
GIT_TAG: ${{ needs.git-version.outputs.git_tag }}
|
||||
steps:
|
||||
-
|
||||
name: Sanitize platform name
|
||||
id: set_platform
|
||||
run: |
|
||||
PLATFORM=$(echo ${{ matrix.platform }} | tr '/' '_')
|
||||
echo "PLATFORM=$PLATFORM" >> $GITHUB_ENV
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
uses: docker/setup-qemu-action@v3
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
uses: docker/setup-buildx-action@v3
|
||||
-
|
||||
name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
-
|
||||
name: Build and push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v2
|
||||
name: Build Binaries
|
||||
id: docker_build_bin
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
platforms: ${{ matrix.platform }}
|
||||
target: runtime
|
||||
outputs: |
|
||||
type=local,dest=./output/${{ env.PLATFORM }}
|
||||
-
|
||||
name: Upload Binaries
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: shioriko-${{ env.PLATFORM }}
|
||||
path: ./output
|
||||
retention-days: 7
|
||||
-
|
||||
name: Build and push (No tag)
|
||||
if: env.IS_LINUX == 'true' && env.IS_RELEASE == 'false'
|
||||
id: docker_build_git
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
push: true
|
||||
platforms: linux/amd64,linux/arm64
|
||||
tags: damillora/shioriko:latest
|
||||
platforms: ${{ matrix.platform }}
|
||||
tags: damillora/shioriko:main
|
||||
-
|
||||
name: Build and push (Tagged)
|
||||
if: env.IS_LINUX == 'true' && env.IS_RELEASE == 'true'
|
||||
id: docker_build_release
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
push: true
|
||||
platforms: ${{ matrix.platform }}
|
||||
tags: damillora/shioriko:${{ env.GIT_TAG }}, damillora/shioriko:latest
|
||||
-
|
||||
name: Image digest
|
||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||
|
23
Dockerfile
23
Dockerfile
@ -1,23 +1,20 @@
|
||||
FROM golang:1.23-alpine AS build
|
||||
|
||||
WORKDIR /go/src/shioriko
|
||||
COPY . .
|
||||
|
||||
RUN go get -d -v ./...
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -o /shioriko -ldflags '-extldflags "-static"' -tags timetzdata
|
||||
RUN mkdir -p /web && cp -r web/static /web
|
||||
|
||||
# Web client
|
||||
FROM node:20-alpine AS node_build
|
||||
WORKDIR /src
|
||||
COPY . .
|
||||
WORKDIR /src/web/app
|
||||
WORKDIR /src/pkg/web
|
||||
RUN npm ci && npm run build
|
||||
|
||||
FROM scratch AS runtime
|
||||
# Go application
|
||||
FROM golang:1.23-alpine AS build
|
||||
WORKDIR /go/src/shioriko
|
||||
COPY . .
|
||||
COPY --from=node_build /src/pkg/web/build/ /go/src/shioriko/pkg/web/build/
|
||||
RUN go get -d -v ./...
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -o /shioriko -ldflags '-extldflags "-static"' -tags timetzdata
|
||||
|
||||
FROM scratch AS runtime
|
||||
WORKDIR /app
|
||||
COPY --from=build /shioriko /app/
|
||||
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||
COPY --from=node_build /src/web/static/ /app/web/static/
|
||||
|
||||
ENTRYPOINT ["/app/shioriko"]
|
||||
|
@ -1,35 +1,17 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"io/fs"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/Damillora/Shioriko/pkg/config"
|
||||
"github.com/Damillora/Shioriko/pkg/database"
|
||||
"github.com/Damillora/Shioriko/pkg/web"
|
||||
"github.com/gin-contrib/cors"
|
||||
"github.com/gin-contrib/static"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type embedFileSystem struct {
|
||||
http.FileSystem
|
||||
}
|
||||
|
||||
func (e embedFileSystem) Exists(prefix string, path string) bool {
|
||||
_, err := e.Open(path)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func EmbedFolder(fsEmbed embed.FS) static.ServeFileSystem {
|
||||
return embedFileSystem{
|
||||
FileSystem: http.FS(fsEmbed),
|
||||
}
|
||||
}
|
||||
|
||||
func Initialize() {
|
||||
config.InitializeConfig()
|
||||
|
||||
@ -49,10 +31,15 @@ func Initialize() {
|
||||
func Start() {
|
||||
g := gin.Default()
|
||||
|
||||
g.StaticFile("/", "./web/static/index.html")
|
||||
g.Static("/_app", "./web/static/_app")
|
||||
webFS := web.WebAssets()
|
||||
webAssets, _ := fs.Sub(webFS, "_app")
|
||||
|
||||
g.NoRoute(func(c *gin.Context) {
|
||||
//c.String(http.StatusOK, "AAA")
|
||||
c.FileFromFS("./app.html", http.FS(webFS))
|
||||
})
|
||||
g.StaticFS("/_app", http.FS(webAssets))
|
||||
g.Static("/data", config.CurrentConfig.DataDirectory)
|
||||
|
||||
g.Use(cors.Default())
|
||||
|
||||
InitializeRoutes(g)
|
||||
|
@ -1,13 +0,0 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func InitializeFrontendRoutes(g *gin.Engine) {
|
||||
g.NoRoute(frontendHome)
|
||||
}
|
||||
|
||||
func frontendHome(c *gin.Context) {
|
||||
c.File("./web/static/index.html")
|
||||
}
|
@ -11,6 +11,4 @@ func InitializeRoutes(g *gin.Engine) {
|
||||
InitializeTagRoutes(g)
|
||||
InitializeBlobRoutes(g)
|
||||
InitializePostRoutes(g)
|
||||
|
||||
InitializeFrontendRoutes(g)
|
||||
}
|
||||
|
0
web/app/.gitignore → pkg/web/.gitignore
vendored
0
web/app/.gitignore → pkg/web/.gitignore
vendored
14
pkg/web/embed.go
Normal file
14
pkg/web/embed.go
Normal file
@ -0,0 +1,14 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"io/fs"
|
||||
)
|
||||
|
||||
//go:embed build/*
|
||||
var webFS embed.FS
|
||||
|
||||
func WebAssets() fs.FS {
|
||||
build, _ := fs.Sub(webFS, "build")
|
||||
return build
|
||||
}
|
0
web/app/src/app.d.ts → pkg/web/src/app.d.ts
vendored
0
web/app/src/app.d.ts → pkg/web/src/app.d.ts
vendored
0
web/app/src/lib/components/ui/PostGallery.svelte → pkg/web/src/lib/components/ui/PostGallery.svelte
0
web/app/src/lib/components/ui/PostGallery.svelte → pkg/web/src/lib/components/ui/PostGallery.svelte
@ -12,8 +12,7 @@ const config = {
|
||||
// If your environment is not supported or you settled on a specific environment, switch out the adapter.
|
||||
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
|
||||
adapter: adapter({
|
||||
fallback: 'index.html', // may differ from host to host,
|
||||
pages: '../static',
|
||||
fallback: 'app.html', // may differ from host to host
|
||||
})
|
||||
},
|
||||
};
|
2
web/static/.gitignore
vendored
2
web/static/.gitignore
vendored
@ -1,2 +0,0 @@
|
||||
*
|
||||
!.gitignore
|
@ -1,4 +0,0 @@
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,15 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<!--Use the title variable to set the title of the page-->
|
||||
<title>{{ .title }}</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta charset="UTF-8" />
|
||||
<script defer src="/static/bundle.js"></script>
|
||||
<link rel="stylesheet" href="/static/bundle.css">
|
||||
<script>
|
||||
window.BASE_URL = {{ .base_url }}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
@ -1,3 +0,0 @@
|
||||
{{ template "header.html" .}}
|
||||
|
||||
{{ template "footer.html" }}
|
Loading…
x
Reference in New Issue
Block a user