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
f70ad689
Commit
f70ad689
authored
Dec 12, 2021
by
steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add dockerfile
parent
527745ad
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
7 deletions
+43
-7
Dockerfile
Dockerfile
+36
-0
.air.toml
scripts/.air.toml
+4
-4
main.go
server/main.go
+1
-1
db.go
store/db.go
+2
-2
No files found.
Dockerfile
0 → 100644
View file @
f70ad689
# Build frontend dist.
FROM
node:14.18.2-alpine3.14 AS frontend
WORKDIR
/frontend-build
COPY
./web/ .
RUN
yarn
RUN
yarn build
# Build backend exec file.
FROM
golang:1.16.12-alpine3.15 AS backend
WORKDIR
/backend-build
RUN
apk
--no-cache
add gcc musl-dev
COPY
. .
RUN
go build
\
-o
memos
\
./server/main.go
# Make workspace with above generated files.
FROM
alpine:3.14.3 AS monolithic
WORKDIR
/usr/local/memos
COPY
--from=backend /backend-build/memos /usr/local/memos/
# Copy default resources, like db file.
COPY
--from=backend /backend-build/resources /usr/local/memos/resources
COPY
--from=frontend /frontend-build/dist /usr/local/memos/web/dist
# Directory to store the data, which can be referenced as the mounting point.
RUN
mkdir
-p
/var/opt/memos/data
CMD
["./memos"]
EXPOSE
8080
scripts/.air.toml
View file @
f70ad689
root
=
"."
tmp_dir
=
"
tmp
"
tmp_dir
=
"
.air
"
[build]
bin
=
"./
tmp/main
"
cmd
=
"go build -o ./
tmp/main .
"
bin
=
"./
.air/memos
"
cmd
=
"go build -o ./
.air/memos ./server/main.go
"
delay
=
1000
exclude_dir
=
[
"
assets"
,
"tmp"
,
"vendo
r"
,
"web"
]
exclude_dir
=
[
"
.ai
r"
,
"web"
]
exclude_file
=
[]
exclude_regex
=
[]
exclude_unchanged
=
false
...
...
main.go
→
server/
main.go
View file @
f70ad689
...
...
@@ -25,5 +25,5 @@ func main() {
r
.
PathPrefix
(
"/"
)
.
Handler
(
spa
)
http
.
ListenAndServe
(
"
localhost
:8080"
,
r
)
http
.
ListenAndServe
(
":8080"
,
r
)
}
store/db.go
View file @
f70ad689
...
...
@@ -14,7 +14,7 @@ import (
var
DB
*
sql
.
DB
func
InitDBConn
()
{
dbFilePath
:=
"/data/memos.db"
dbFilePath
:=
"/
var/opt/memos/
data/memos.db"
if
_
,
err
:=
os
.
Stat
(
dbFilePath
);
err
!=
nil
{
dbFilePath
=
"./resources/memos.db"
...
...
@@ -27,7 +27,7 @@ func InitDBConn() {
db
,
err
:=
sql
.
Open
(
"sqlite3"
,
dbFilePath
)
if
err
!=
nil
{
p
rintln
(
"
connect failed"
)
p
anic
(
"db
connect failed"
)
}
else
{
DB
=
db
println
(
"connect to sqlite succeed"
)
...
...
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