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
4180613f
Commit
4180613f
authored
Jan 20, 2026
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: update demo mode handling
parent
324f7959
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
9 deletions
+16
-9
AGENTS.md
AGENTS.md
+3
-3
profile.go
internal/profile/profile.go
+10
-2
Dockerfile
scripts/Dockerfile
+0
-1
build.sh
scripts/build.sh
+1
-1
DEMO_DATA_GUIDE.md
store/seed/DEMO_DATA_GUIDE.md
+2
-2
No files found.
AGENTS.md
View file @
4180613f
...
@@ -191,7 +191,7 @@ cd proto && buf generate
...
@@ -191,7 +191,7 @@ cd proto && buf generate
```
bash
```
bash
# Start dev server
# Start dev server
go run ./cmd/memos
--
mode
dev
--
port
8081
go run ./cmd/memos
--port
8081
# Run all tests
# Run all tests
go
test
./...
go
test
./...
...
@@ -458,7 +458,7 @@ cd web && pnpm lint
...
@@ -458,7 +458,7 @@ cd web && pnpm lint
| Variable | Default | Description |
| Variable | Default | Description |
|----------|----------|-------------|
|----------|----------|-------------|
| `MEMOS_
MODE` | `dev` | Mode: `dev`, `prod`, `demo`
|
| `MEMOS_
DEMO` | `false` | Enable demo mode
|
| `MEMOS_PORT` | `8081` | HTTP port |
| `MEMOS_PORT` | `8081` | HTTP port |
| `MEMOS_ADDR` | `` | Bind address (empty = all) |
| `MEMOS_ADDR` | `` | Bind address (empty = all) |
| `MEMOS_DATA` | `~/.memos` | Data directory |
| `MEMOS_DATA` | `~/.memos` | Data directory |
...
@@ -564,7 +564,7 @@ Each plugin has its own README with usage examples.
...
@@ -564,7 +564,7 @@ Each plugin has its own README with usage examples.
## Security Notes
## Security Notes
-
JWT secrets must be kept secret (
`MEMOS_MODE=prod`
generates random secret
)
-
JWT secrets must be kept secret (
generated on first run in production mode
)
-
Personal Access Tokens stored as SHA-256 hashes in database
-
Personal Access Tokens stored as SHA-256 hashes in database
-
CSRF protection via SameSite cookies
-
CSRF protection via SameSite cookies
-
CORS enabled for all origins (configure for production)
-
CORS enabled for all origins (configure for production)
...
...
internal/profile/profile.go
View file @
4180613f
...
@@ -57,14 +57,22 @@ func (p *Profile) Validate() error {
...
@@ -57,14 +57,22 @@ func (p *Profile) Validate() error {
// Set default data directory if not specified
// Set default data directory if not specified
if
p
.
Data
==
""
{
if
p
.
Data
==
""
{
if
p
.
Demo
{
if
p
.
Demo
{
// In demo mode, use
a temporary directory or
current directory
// In demo mode, use current directory
p
.
Data
=
"."
p
.
Data
=
"."
}
else
{
}
else
{
// In production mode, use system directory
// In production mode, use system directory
if
runtime
.
GOOS
==
"windows"
{
if
runtime
.
GOOS
==
"windows"
{
p
.
Data
=
filepath
.
Join
(
os
.
Getenv
(
"ProgramData"
),
"memos"
)
p
.
Data
=
filepath
.
Join
(
os
.
Getenv
(
"ProgramData"
),
"memos"
)
}
else
{
}
else
{
// On Linux/macOS, check if /var/opt/memos exists (Docker scenario)
// If not, fall back to current directory to avoid permission issues
if
_
,
err
:=
os
.
Stat
(
"/var/opt/memos"
);
err
==
nil
{
p
.
Data
=
"/var/opt/memos"
p
.
Data
=
"/var/opt/memos"
}
else
{
slog
.
Warn
(
"default production data directory /var/opt/memos not accessible, using current directory. "
+
"Consider using --data flag to specify a data directory."
)
p
.
Data
=
"."
}
}
}
}
}
}
}
...
...
scripts/Dockerfile
View file @
4180613f
...
@@ -47,7 +47,6 @@ USER nonroot:nonroot
...
@@ -47,7 +47,6 @@ USER nonroot:nonroot
VOLUME
/var/opt/memos
VOLUME
/var/opt/memos
ENV
TZ="UTC" \
ENV
TZ="UTC" \
MEMOS_MODE="prod" \
MEMOS_PORT="5230"
MEMOS_PORT="5230"
EXPOSE
5230
EXPOSE
5230
...
...
scripts/build.sh
View file @
4180613f
...
@@ -29,4 +29,4 @@ go build -o "$OUTPUT" ./cmd/memos
...
@@ -29,4 +29,4 @@ go build -o "$OUTPUT" ./cmd/memos
echo
"Build successful!"
echo
"Build successful!"
echo
"To run the application, execute the following command:"
echo
"To run the application, execute the following command:"
echo
"
$OUTPUT
--mode dev
"
echo
"
$OUTPUT
"
store/seed/DEMO_DATA_GUIDE.md
View file @
4180613f
...
@@ -174,10 +174,10 @@ To run with demo data:
...
@@ -174,10 +174,10 @@ To run with demo data:
```
bash
```
bash
# Start in demo mode
# Start in demo mode
go run ./cmd/memos
--
mode
demo
--port
8081
go run ./cmd/memos
--demo
--port
8081
# Or use the binary
# Or use the binary
./memos
--
mode
demo
./memos
--demo
# Demo database location
# Demo database location
./build/memos_demo.db
./build/memos_demo.db
...
...
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