Giter Club home page Giter Club logo

twikoo-docker's Introduction

⚠ 本仓库代码已合并到 github.com/imaegoo/twikoo,本仓库不再维护

Twikoo Docker Image

Twikoo 私有部署 Docker 镜像。

部署指南

使用 Docker 部署

  1. 安装 Docker,以 Ubuntu 系统为例:
curl -fsSL https://get.docker.com -o get-docker.sh  # 下载安装脚本
sudo sh get-docker.sh                               # 安装 docker
sudo usermod -aG docker $USER                       # 将当前用户加入 docker 用户组
  1. 启动 Twikoo:
docker run -p 8080:8080 -v ${PWD}/data:/app/data -d imaegoo/twikoo

如果镜像下载速度慢,可以将命令中的 imaegoo/twikoo 替换成 registry.cn-hangzhou.aliyuncs.com/imaegoo/twikoo

默认端口 8080,如果遇到端口冲突问题,请修改命令中的 8080:8080自定义端口:8080

  1. 测试 Twikoo:
curl http://localhost:8080/

如果您看到类似 “Twikoo 云函数运行正常” 的提示,那么 Twikoo 已经部署成功。

  1. 配置前置 Nginx 服务器或负载网关,以通过 HTTPS 访问 Twikoo,如下 Nginx 配置可供参考,过程略。
# ......
http {
    # ......
    server {
        listen       80;
        listen       [::]:80;
        return       301 https://$server_name$request_uri;
    }
    server {
        listen       443 ssl;
        listen       [::]:443 ssl;
        ssl_certificate      cert/fullchain.pem;
        ssl_certificate_key  cert/privkey.pem;
        location / {
            proxy_pass   http://127.0.0.1:8080;
        }
    }
}

不使用 Docker 部署

  1. 服务端下载安装 Node.js
  2. 安装 Twikoo server: npm i -g tkserver
  3. 根据需要配置环境变量
名称 描述 默认值
TWIKOO_DATA 数据库存储路径 ./data
TWIKOO_PORT 端口号 8080
TWIKOO_THROTTLE IP 请求限流,当同一 IP 短时间内请求次数超过阈值将对该 IP 返回错误 250
  1. 启动 Twikoo server: tkserver
  2. 访问 http://服务端IP:8080
  3. 若能正常访问,服务端地址(包含 http:// 和端口号,例如 http://12.34.56.78:8080)即为您的环境 id

其他事项

  1. Linux 服务器可以用 nohup tkserver >> tkserver.log 2>&1 & 命令后台启动
  2. 强烈建议配置前置 nginx 服务器并配置 https 证书
  3. 数据在服务器上,请注意定期备份数据

twikoo-docker's People

Contributors

imaegoo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

lucky-dj zxmacc

twikoo-docker's Issues

注册失败

使用 docker logs 查看日志发现如下错误

Twikoo 遇到错误,请参考以下错误信息。如有疑问,请反馈至 https://github.com/imaegoo/twikoo/issues
请求参数: {}
错误信息: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
    at new NodeError (internal/errors.js:322:7)
    at ServerResponse.setHeader (_http_outgoing.js:561:11)
    at allowCors (/app/node_modules/twikoo-vercel/api/index.js:155:14)
    at module.exports (/app/node_modules/twikoo-vercel/api/index.js:66:5)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5) {
  code: 'ERR_HTTP_HEADERS_SENT'
}
请求返回: {
  code: 1000,
  message: 'Cannot set headers after they are sent to the client'
}
(node:1) UnhandledPromiseRejectionWarning: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
    at new NodeError (internal/errors.js:322:7)
    at ServerResponse.setHeader (_http_outgoing.js:561:11)
    at ServerResponse.writeHead (_http_server.js:293:21)
    at ServerResponse.response.json (/app/index.js:11:10)
    at module.exports (/app/node_modules/twikoo-vercel/api/index.js:150:24)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

发送通知失败

错误日志:

SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /opt/twikoo-docker/index.js:48:27
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /opt/twikoo-docker/index.js:48:27
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /opt/twikoo-docker/index.js:48:27
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /opt/twikoo-docker/index.js:48:27
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /opt/twikoo-docker/index.js:48:27
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /opt/twikoo-docker/index.js:48:27
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /opt/twikoo-docker/index.js:48:27
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /opt/twikoo-docker/index.js:48:27
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /opt/twikoo-docker/index.js:48:27
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /opt/twikoo-docker/index.js:48:27
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /opt/twikoo-docker/index.js:48:27
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
(node:135521) Warning: Label 'POST_SUBMIT' already exists for console.time()
(Use `node --trace-warnings ...` to show where the warning was created)
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /opt/twikoo-docker/index.js:48:27
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /opt/twikoo-docker/index.js:48:27
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /opt/twikoo-docker/index.js:48:27
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /opt/twikoo-docker/index.js:48:27
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /opt/twikoo-docker/index.js:48:27
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /opt/twikoo-docker/index.js:48:27
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /opt/twikoo-docker/index.js:48:27
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /opt/twikoo-docker/index.js:48:27
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /opt/twikoo-docker/index.js:48:27
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /opt/twikoo-docker/index.js:48:27
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /opt/twikoo-docker/index.js:48:27
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /opt/twikoo-docker/index.js:48:27
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
(node:135521) Warning: Label 'POST_SUBMIT' already exists for console.time()
(node:135521) Warning: Label 'POST_SUBMIT' already exists for console.time()
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /opt/twikoo-docker/index.js:48:27
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /opt/twikoo-docker/index.js:48:27
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /opt/twikoo-docker/index.js:48:27
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /opt/twikoo-docker/index.js:48:27
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
(node:135521) Warning: Label 'POST_SUBMIT' already exists for console.time()
(node:135521) Warning: Label 'POST_SUBMIT' already exists for console.time()
(node:135521) Warning: Label 'POST_SUBMIT' already exists for console.time()
(node:135521) Warning: Label 'POST_SUBMIT' already exists for console.time()

端口无法修改

修改yaml端口为
ports:
- 8777:8777
但服务依旧在8080
请问是我配置错了还是bug?
大佬带带

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.