# 前言
最近入了思源笔记的坑,想好好的捣鼓捣鼓。去年在自己的极空间 NAS 上部署了思源笔记的 Docker 版,但版本已经跟不上了(D 大和 V 姐的更新太频繁了🤣),借助极空间论坛里大佬的帮助,我们自己也可以编译适配极空间 Z4 的最新版思源笔记 Docker 镜像了,于是在此记录下编译的过程~
# 编译环境
- Ubuntu:Ubuntu 20.04.4 LTS x86_64
- Docker
- Git
# 步骤
# 拉取思源笔记最新源码
git clone https://github.com/siyuan-note/siyuan.git |
# 拉取大佬的 zsource 仓库
git clone https://github.com/zs0urce/zsource.git |
浏览了下大佬的 Dockerfile.z4
文件,发现大佬主要是将 addgroup --gid 1000 siyuan && adduser --uid 1000 --ingroup siyuan --disabled-password siyuan
这个创建普通用户的命令去掉了,然后将 USER siyuan
这个指定用户的命令也去掉了,这样就可以使用 root 用户了,从而解决极空间 Z4 上的权限问题了
# 拷贝
拷贝大佬项目中 siyuan 目录下的所有文件到思源笔记仓库代码目录中
国内的网络环境真的是太恶劣了,为了解决环境问题,深夜踩坑了一晚上,在更改了下 Dockerfile.z4
文件后,终于解决了,欣慰啊
文件中需要更改的地方我都已经高亮标出了~
FROM node:16 as NODE_BUILD | |
WORKDIR /go/src/github.com/siyuan-note/siyuan/ | |
ADD . /go/src/github.com/siyuan-note/siyuan/ | |
RUN cd app && npm install -g pnpm && ELECTRON_MIRROR=https://cnpmjs.org/mirrors/electron/ pnpm install electron@21.4.2 -D && pnpm install && pnpm run build | |
FROM golang:1.19-alpine as GO_BUILD | |
WORKDIR /go/src/github.com/siyuan-note/siyuan/ | |
COPY /go/src/github.com/siyuan-note/siyuan/ /go/src/github.com/siyuan-note/siyuan/ | |
ENV GO111MODULE=on | |
ENV CGO_ENABLED=1 | |
ENV GOPROXY=https://goproxy.cn,direct | |
RUN apk add --no-cache gcc musl-dev git && \ | |
git config --global http.https://github.com.proxy socks5://192.168.1.101:10808 && git config --global https.https://github.com.proxy socks5://192.168.1.101:10808 && \ | |
cd kernel && go build --tags fts5 -v -ldflags "-s -w -X github.com/siyuan-note/siyuan/kernel/util.Mode=prod" && \ | |
mkdir /opt/siyuan/ && \ | |
mv /go/src/github.com/siyuan-note/siyuan/app/appearance/ /opt/siyuan/ && \ | |
mv /go/src/github.com/siyuan-note/siyuan/app/stage/ /opt/siyuan/ && \ | |
mv /go/src/github.com/siyuan-note/siyuan/app/guide/ /opt/siyuan/ && \ | |
mv /go/src/github.com/siyuan-note/siyuan/kernel/kernel /opt/siyuan/ && \ | |
find /opt/siyuan/ -name .git | xargs rm -rf | |
FROM ghcr.io/linuxserver/baseimage-alpine:3.16 | |
LABEL maintainer="wangyu<wangyu0814@foxmail.com>" | |
WORKDIR /opt/siyuan/ | |
COPY /opt/siyuan/ /opt/siyuan/ | |
RUN \ | |
apk add --no-cache \ | |
ca-certificates \ | |
tzdata && \ | |
echo "**** cleanup ****" && \ | |
rm -rf \ | |
/root/.cache \ | |
/tmp/* | |
# copy local files | |
COPY root/ / | |
ENV TZ=Asia/Shanghai | |
ENV WORKSPACE=/siyuan/workspace/ | |
ENV ACCESSAUTHCODE= | |
ENV PUID=0 | |
ENV PGID=0 | |
VOLUME /siyuan/workspace/ | |
EXPOSE 6806 |
# 编译
sudo sh ./build_z4.sh |
成功之后,就可以参考我之前的文章【极空间上常用 Docker 应用推荐 - 可玩性 +++】进行部署啦,bingo~
在此放一张编译成功,以及成功部署后的图吧,镇帖 (๑・̀ㅂ・́)و✧