Files
siyuan/Dockerfile
T
Jeffrey Chen 1f5361096b 👷 Trim the changelog during packaging (#17889)
* 🎨 Trim the changelog during packaging

* refactor: extract changelog trim logic into independent script

- Move trimChangelogs() from afterPack.js to new scripts/trimChangelogs.js
- afterPack.js now imports and delegates to the independent module
- Dockerfile calls the independent script instead of afterPack.js

---------

Co-authored-by: Daniel <845765@qq.com>
2026-06-20 19:19:42 +08:00

61 lines
1.5 KiB
Docker

FROM --platform=$BUILDPLATFORM node:21 AS node-build
ARG NPM_REGISTRY=
WORKDIR /app
ADD app/package.json app/pnpm* app/.npmrc .
RUN <<EORUN
#!/bin/bash -e
corepack enable
corepack install --global $(node -e 'console.log(require("./package.json").packageManager)')
npm config set registry ${NPM_REGISTRY}
pnpm install --silent
EORUN
ADD app/ .
RUN <<EORUN
#!/bin/bash -e
pnpm run build
node scripts/trimChangelogs.js
mkdir /artifacts
mv appearance stage guide changelogs /artifacts/
EORUN
FROM golang:1.25-alpine AS go-build
RUN <<EORUN
#!/bin/sh -e
apk add --no-cache gcc musl-dev
go env -w GO111MODULE=on
go env -w CGO_ENABLED=1
EORUN
WORKDIR /kernel
ADD kernel/go.* .
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg \
go mod download
ADD kernel/ .
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg \
go build -tags fts5 -ldflags "-s -w"
FROM alpine:latest
LABEL maintainer="Liang Ding<845765@qq.com>"
RUN apk add --no-cache ca-certificates tzdata su-exec
ENV TZ=Asia/Shanghai
ENV HOME=/home/siyuan
ENV RUN_IN_CONTAINER=true
EXPOSE 6806
WORKDIR /opt/siyuan/
COPY --from=go-build --chmod=755 /kernel/kernel /kernel/entrypoint.sh .
COPY --from=node-build /artifacts .
ENTRYPOINT ["/opt/siyuan/entrypoint.sh"]
# 默认启动伺服。若通过 `docker run` / `command:` 传额外参数,需自行带上 `serve` 子命令,
# 否则用户参数会整体覆盖 CMD。
CMD ["/opt/siyuan/kernel", "serve"]