tangly1024 / NotionNext

使用 NextJS + Notion API 实现的,支持多种部署方案的静态博客,无需服务器、零门槛搭建网站,为Notion和所有创作者设计。 (A static blog built with NextJS and Notion API, supporting multiple deployment options. No server required, zero threshold to set up a website. Designed for Notion and all creators.)
https://tangly1024.com
MIT License
7.24k stars 10.1k forks source link

【环境变量】Docker配置环境变量无效NEXT_PUBLIC_THEME #2600

Open zhang1zh opened 2 months ago

zhang1zh commented 2 months ago

描述遇到的问题 通过docker部署notionnext设置主题环境变量NEXT_PUBLIC_THEME无作用

相应配置 docker-compose配置如下:

services:
  notionnext:
    container_name: notionnext
    image: ghcr.io/tangly1024/notionnext:main
    ports:
      - 3333:3000
    environment: 
      NOTION_PAGE_ID: 24185cda07434fec80f93aab677d8455
      NEXT_PUBLIC_THEME: heo
    networks:
      - default
      - default_bridge
    labels:
      - traefik.http.routers.notionnext-main.rule=Host(`test.poohpooh.cn`)
    restart: always
networks:
  default_bridge:
    external: true

截图 正常应该根据环境变量中NEXT_PUBLIC_THEME为heo的配置,应用heo主题,但是无效果,在notion-config中配置THEME可以

image

环境

root@Tower:~# docker images|grep notion
ghcr.io/tangly1024/notionnext                main           845fc23eeec1   6 days ago     931MB
root@Tower:~# docker exec -it notionnext /bin/sh
/app # env
NEXT_PUBLIC_THEME=heo
NODE_VERSION=18.20.3
HOSTNAME=8a382cc135c4
YARN_VERSION=1.22.19
SHLVL=1
HOME=/root
TERM=xterm
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/app
NOTION_PAGE_ID=24185cda07434fec80f93aab677d8455
NODE_ENV=production
tangly1024 commented 1 month ago

目前Dockerfile里只支持了 NOTION_PAGE_ID 这一环境变量

ARG NOTION_PAGE_ID
# Install dependencies only when needed
FROM node:18-alpine3.18 AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json ./
RUN yarn install --frozen-lockfile

# Rebuild the source code only when needed
FROM node:18-alpine3.18 AS builder
ARG NOTION_PAGE_ID
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN yarn build

ENV NODE_ENV production

EXPOSE 3000

# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry.
# ENV NEXT_TELEMETRY_DISABLED 1

CMD ["yarn", "start"]
imrayyu commented 1 month ago

同样的问题,修改环境变量后直接把默认的主题覆盖在了指定变量的主题上了,并没有切换,还是默认的主题。

tangly1024 commented 1 week ago

最新提交中增加了 NEXT_PUBLIC_THEME的支持 https://github.com/tangly1024/NotionNext/commit/d0a4acd5c34ee0e78ef507ff784d046bcb7c1fb4