Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
273d6a69
Commit
273d6a69
authored
Dec 23, 2023
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update dockerfile
parent
95314181
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
50 deletions
+7
-50
Dockerfile
Dockerfile
+1
-1
index.html
server/frontend/dist/index.html
+0
-14
frontend.go
server/frontend/frontend.go
+6
-35
No files found.
Dockerfile
View file @
273d6a69
...
...
@@ -15,7 +15,6 @@ FROM golang:1.21-alpine AS backend
WORKDIR
/backend-build
COPY
. .
COPY
--from=frontend /frontend-build/web/dist ./server/frontend/dist
RUN
CGO_ENABLED
=
0 go build
-o
memos ./bin/memos/main.go
...
...
@@ -26,6 +25,7 @@ WORKDIR /usr/local/memos
RUN
apk add
--no-cache
tzdata
ENV
TZ="UTC"
COPY
--from=frontend /frontend-build/web/dist /usr/local/memos/dist
COPY
--from=backend /backend-build/memos /usr/local/memos/
EXPOSE
5230
...
...
server/frontend/dist/index.html
deleted
100644 → 0
View file @
95314181
<!-- THIS FILE IS A PLACEHOLDER AND SHOULD NOT BE CHANGED -->
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
/>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
/>
<title>
Memos
</title>
<!-- memos.metadata -->
</head>
<body>
<p>
No frontend embeded.
</p>
</body>
</html>
server/frontend/frontend.go
View file @
273d6a69
package
frontend
import
(
"embed"
"fmt"
"html/template"
"io/fs"
"net/http"
"os"
"strings"
"github.com/labstack/echo/v4"
...
...
@@ -20,12 +19,6 @@ import (
"github.com/usememos/memos/store"
)
//go:embed dist
var
embeddedFiles
embed
.
FS
//go:embed dist/index.html
var
rawIndexHTML
string
type
FrontendService
struct
{
Profile
*
profile
.
Profile
Store
*
store
.
Store
...
...
@@ -42,32 +35,18 @@ func (s *FrontendService) Serve(e *echo.Echo) {
// Use echo static middleware to serve the built dist folder.
// refer: https://github.com/labstack/echo/blob/master/middleware/static.go
e
.
Use
(
middleware
.
StaticWithConfig
(
middleware
.
StaticConfig
{
Skipper
:
defaultAPIRequestSkipper
,
HTML5
:
true
,
Filesystem
:
getFileSystem
(
"dist"
),
}))
assetsGroup
:=
e
.
Group
(
"assets"
)
assetsGroup
.
Use
(
middleware
.
GzipWithConfig
(
middleware
.
GzipConfig
{
Root
:
"dist"
,
Skipper
:
defaultAPIRequestSkipper
,
Level
:
5
,
}))
assetsGroup
.
Use
(
func
(
next
echo
.
HandlerFunc
)
echo
.
HandlerFunc
{
return
func
(
c
echo
.
Context
)
error
{
c
.
Response
()
.
Header
()
.
Set
(
echo
.
HeaderCacheControl
,
"max-age=31536000, immutable"
)
return
next
(
c
)
}
})
assetsGroup
.
Use
(
middleware
.
StaticWithConfig
(
middleware
.
StaticConfig
{
Skipper
:
defaultAPIRequestSkipper
,
HTML5
:
true
,
Filesystem
:
getFileSystem
(
"dist/assets"
),
HTML5
:
true
,
}))
s
.
registerRoutes
(
e
)
}
func
(
s
*
FrontendService
)
registerRoutes
(
e
*
echo
.
Echo
)
{
rawIndexHTMLBytes
,
_
:=
os
.
ReadFile
(
"dist/index.html"
)
rawIndexHTML
:=
string
(
rawIndexHTMLBytes
)
e
.
GET
(
"/robots.txt"
,
func
(
c
echo
.
Context
)
error
{
ctx
:=
c
.
Request
()
.
Context
()
instanceURLSetting
,
err
:=
s
.
Store
.
GetSystemSetting
(
ctx
,
&
store
.
FindSystemSetting
{
...
...
@@ -194,14 +173,6 @@ func generateMemoMetadata(memo *store.Memo, creator *store.User) string {
return
strings
.
Join
(
metadataList
,
"
\n
"
)
}
func
getFileSystem
(
path
string
)
http
.
FileSystem
{
fs
,
err
:=
fs
.
Sub
(
embeddedFiles
,
path
)
if
err
!=
nil
{
panic
(
err
)
}
return
http
.
FS
(
fs
)
}
func
defaultAPIRequestSkipper
(
c
echo
.
Context
)
bool
{
path
:=
c
.
Request
()
.
URL
.
Path
return
util
.
HasPrefixes
(
path
,
"/api"
,
"/memos.api.v2"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment