# based on https://github.com/siyuan-note/siyuan/blob/master/Dockerfile FROM node:21 as NODE_BUILD ARG COMMIT=3eec016723f52f3a679fb99854ae33e8fe20e42a # fetch and patch ADD *.patch /patches/ RUN apt-get update && \ apt-get install -y git jq && \ git clone https://github.com/siyuan-note/siyuan.git /go/src/github.com/siyuan-note/siyuan/ --depth=1 && \ cd /go/src/github.com/siyuan-note/siyuan/ && \ git fetch --depth=1 origin ${COMMIT} && \ git checkout ${COMMIT} && \ git submodule update --init --recursive && \ git apply /patches/license.patch WORKDIR /go/src/github.com/siyuan-note/siyuan/ # the rest is pretty much the same as the official Dockerfile RUN cd app && \ packageManager=$(jq -r '.packageManager' package.json) && \ if [ -n "$packageManager" ]; then \ npm install -g $packageManager; \ else \ echo "No packageManager field found in package.json"; \ npm install -g pnpm; \ fi && \ pnpm install --registry=http://registry.npmjs.org/ --silent && \ pnpm run build RUN apt-get purge -y jq RUN apt-get autoremove -y RUN rm -rf /var/lib/apt/lists/* FROM golang:alpine as GO_BUILD WORKDIR /go/src/github.com/siyuan-note/siyuan/ COPY --from=NODE_BUILD /go/src/github.com/siyuan-note/siyuan/ /go/src/github.com/siyuan-note/siyuan/ ENV GO111MODULE=on ENV CGO_ENABLED=1 RUN apk add --no-cache gcc musl-dev && \ cd kernel && go build --tags fts5 -v -ldflags "-s -w" && \ 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/app/changelogs/ /opt/siyuan/ && \ mv /go/src/github.com/siyuan-note/siyuan/kernel/kernel /opt/siyuan/ && \ find /opt/siyuan/ -name .git | xargs rm -rf FROM alpine:latest LABEL maintainer="Liang Ding<845765@qq.com>" WORKDIR /opt/siyuan/ COPY --from=GO_BUILD /opt/siyuan/ /opt/siyuan/ RUN addgroup --gid 1113 siyuan && adduser --uid 1113 --ingroup siyuan --disabled-password siyuan && apk add --no-cache ca-certificates tzdata && chown -R siyuan:siyuan /opt/siyuan/ ENV TZ=Asia/Shanghai ENV RUN_IN_CONTAINER=true EXPOSE 6806 USER siyuan ENTRYPOINT ["/opt/siyuan/kernel"]