RainEggplant / chatgpt-telegram-bot

A ChatGPT bot for Telegram based on Node.js. Support both browserless and browser-base APIs.
MIT License
323 stars 97 forks source link

[Feature Request]: Docker config.json auto generate #48

Open soyelmismo opened 1 year ago

soyelmismo commented 1 year ago

Not a duplicate feature request

Describe the feature

Please add something to auto generate the default.json file in a binded volume when the file doesn't exists, this is useful when you want to use the new file with new update features, and can save time by skipping the manual copy and paste from the repo

soyelmismo commented 1 year ago

If I delete the previous generated file and update the container and try to run it gives this error because the file doesn't exists anymore



WARNING: To disable this warning set SUPPRESS_NO_CONFIG_WARNING in the environment.

Error: Configuration property "api.type" is not defined

    at Config.get (/app/node_modules/.pnpm/config@3.3.9/node_modules/config/lib/config.js:179:11)

    at loadConfig (file:///app/dist/utils.js:20:28)

    at main (file:///app/dist/index.js:7:18)

    at file:///app/dist/index.js:22:1

    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)

 ELIFECYCLE  Command failed with exit code 1.```
soyelmismo commented 1 year ago

So maybe environment variables can be added to auto generate a new file after an update specifying API type and token

Vadko commented 1 year ago

this probably is related to the Dockerfile config. Could you please try this dockerfile:

# Builder stage
FROM node:lts-alpine AS builder

RUN npm install -g pnpm

WORKDIR /app

COPY config /app/config
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile --ignore-scripts

COPY . .
RUN pnpm build

# Runner stage
FROM node:lts-alpine

RUN npm install -g pnpm

WORKDIR /app

COPY config /app/config
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile --ignore-scripts --prod --no-optional

COPY --from=builder /app/dist ./dist

CMD pnpm start