memos 轻量级的自托管笔记应用
# 软件简介
memos 是一个具有知识管理的开源自托管笔记应用。
特点
* 开源且永远免费
* 在几秒钟内使用 Docker 自托管
* 支持 Markdown
* 可定制和可共享
* 用于自助服务的 RESTful API
# 使用 Docker 进行部署
```
docker run -d --name memos -p 5230:5230 -v ~/.memos/:/var/opt/memos neosmemo/memos:latest
```
> `~/.memos/` 目录将用作本地计算机上的数据目录,而 `/var/opt/memos` 是在 Docker 中的卷目录,不应该被修改。
>
> 文档链接:[https://www.usememos.com/docs](https://www.usememos.com/docs)
# 编译代码进行部署
* 拉取代码:
```
git clone https://gitee.com/mirrors/memos.git
git checkout v0.20.0
#替换v0.20.0为最新版本号
```
* 修改文件memo/script/build.sh,选择编译的CPU架构
* 安装nodejs环境和golang环境,必须安装pnpm:
```
npm install pnpm
```
```
bash script/build.sh #build.sh文件内容在文末
```
* 开始部署服务
新建memos目录,将memos-linux-***文件拷贝到memos目录中。
```
sudo ln -s /path/to/memos /var/opt/
```
在memos目录中新建文件start.sh
> #!/bin/bash
>
> cd /path/to/memos/
> ./memos-linux-*** --mode prod --port <端口号(默认为8081)>
在/lib/systemd/system/目录中新建文件memos.service
> Description=memos
> After=network.target
>
> [Service]
>
> User=tzuos
> Group=tzuos
> ExecStart=bash /path/to/memos/start.sh
>
> [Install]
> WantedBy=multi-user.target
```
sudo systemctl enable memos
sudo systemctl start memos
```
结束,有变化再来补充。
### 下面这个是编译脚本:
```
#!/bin/bash
# This script builds memos for all listed platforms.
# It's only for local builds.
# Before using, setup a proper development environment as described here:
# * https://usememos.com/docs/contribution/development
# * https://github.com/usememos/memos/blob/main/docs/development.md
# Requirements:
# * go
# * node.js
# * npm
# Usage:
# chmod +x ./scripts/build.sh
# ./scripts/build.sh
#
# Output: ./build/memos-<os>-<arch>[.exe]
goBuilds=(
# "darwin/amd64"
# "darwin/arm64"
"linux/amd64"
"linux/arm64"
# "windows/amd64"
)
ldFlags=(
"-s" # Omit symbol table and debug information
"-w" # Omit DWARF symbol table
)
##
find_repo_root() {
# Usage: find_repo_root <file_at_root> <dir1> <dir2> ...
local looking_for="${1:-".gitignore"}"
shift
local default_dirs=("." "../")
local dirs=("${@:-${default_dirs[@]}}")
for dir in "${dirs[@]}"; do
if [ -f "$dir/$looking_for" ]; then
echo $(realpath "$dir")
return
fi
done
}
repo_root=$(find_repo_root)
if [ -z "$repo_root" ]; then
echo -e "\033[0;31mRepository root not found! Exiting.\033[0m"
exit 1
else
echo -e "Repository root: \033[0;34m$repo_root\033[0m"
fi
pushd $repo_root
cd "$repo_root/web"
if ! command -v pnpm &>/dev/null; then
echo -e "\n\033[35mInstalling pnpm...\033[0m"
npm install -g pnpm
if [ $? -ne 0 ]; then
echo -e "\033[0;31mFailed to install pnpm! Exiting.\033[0m"
popd
exit 1
fi
fi
echo -e "\n\033[33mInstalling frontend dependencies...\033[0m"
pnpm i --frozen-lockfile
if [ $? -ne 0 ]; then
echo -e "\033[0;31mFrontend dependencies failed to install! Exiting.\033[0m"
popd
exit 1
fi
echo -e "\033[32mFrontend dependencies installed!\033[0m"
echo -e "\n\033[35mRemoving previous frontend build from ./build/dist...\033[0m"
rm -rf $repo_root/build/dist
if [ $? -ne 0 ]; then
echo -e "\033[93mCould not remove frontend from ./build/dist.\033[0m"
popd
exit 1
fi
echo -e "\n\033[33mBuilding frontend...\033[0m"
pnpm build
if [ $? -ne 0 ]; then
echo -e "\033[0;31mFrontend build failed! Exiting.\033[0m"
popd
exit 1
fi
echo -e "\033[32mFrontend built!\033[0m"
cd $repo_root
echo -e "\033[35mMoving frontend build to ./build/dist...\033[0m"
rm -rf "$repo_root/server/router/frontend/dist/"
mv -f "$repo_root/web/dist" "$repo_root/server/router/frontend/"
if [ $? -ne 0 ]; then
echo -e "\033[0;31mFailed to move frontend build! Exiting.\033[0m"
popd
exit 1
fi
cd "$repo_root"
echo -e "\n\033[33mBuilding backend...\033[0m"
for build in "${goBuilds[@]}"; do
os=$(echo $build | cut -d'/' -f1)
arch=$(echo $build | cut -d'/' -f2)
output="$repo_root/build/memos-$os-$arch"
if [ "$os" = "windows" ]; then
output="$output.exe"
fi
CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build -trimpath -ldflags="${ldFlags[*]}" -o "$output" ./bin/memos/main.go
echo -e "\033[34mBuilding $os/$arch to $output...\033[0m"
GOOS=$os GOARCH=$arch go build -ldflags="${ldFlags[*]}" -o "./build/memos-$os-$arch" ./bin/memos/main.go
if [ $? -ne 0 ]; then
echo -e "\033[0;31mgo build failed for $os/$arch($output)! See above.\033[0m"
fi
done
echo -e "\033[32mBackend built!\033[0m"
echo -e "\n\033[37mBuilds:\033[0m"
for build in "${goBuilds[@]}"; do
os=$(echo $build | cut -d'/' -f1)
arch=$(echo $build | cut -d'/' -f2)
output="$repo_root/build/memos-$os-$arch"
if [ "$os" = "windows" ]; then
output="$output.exe"
fi
echo -e "\033[37m$output\033[0m"
done
echo -e "\n\033[32mYou can test the build with \033[37m./build/memos-<os>-<arch>\033[0m\033[90m.exe\033[0m \033[37m--mode demo\033[0m"
cd $repo_root
```
- 共 0 条回复
- 需要登录 后方可回复, 如果你还没有账号请点击这里注册。
wiseAI
✨ 梦初醒 茅塞开
- 不经他人苦,莫劝他人善。
- 能量足,心态稳,温和坚定可以忍。
- 辛苦决定不了收入,真正决定收入的只有一个,就是不可替代性。
- 要么忙于生存,要么赶紧去死!
- 内心强大到混蛋,比什么都好!
- 规范流程比制定制度更重要!
-
立志需要高远,但不能急功近利;
行动需要迅速,却不可贪图速成。 - 不要强求人品,要设计高效的机制。
-
你弱的时候,身边都是鸡零狗碎;
你强的时候,身边都是风和日丽。 - 机制比人品更可靠,契约比感情更可靠。
- 合作不意味着没有冲突,却是控制冲突的最好方法。
- 误解是人生常态,理解本是稀缺的例外。
- 成功和不成功之间,只差一次坚持!
- 祁连卧北雪,大漠壮雄关。
- 利益顺序,过程公开,机会均等,付出回报。
