【问题标题】:Deploying n8n to Heroku将 n8n 部署到 Heroku
【发布时间】:2020-07-28 09:09:51
【问题描述】:

我在通过 Docker 注册表将 n8n 部署到 Heroku 时遇到问题,无法弄清楚我做错了什么。 任何帮助将不胜感激。

手动配置 Postgres 版本 11:

heroku addons:create heroku-postgresql:hobby-dev --version=11 -a my-app

Dockerfile:

FROM n8nio/n8n

heroku.yml:

setup:
  #addons:
  #  - plan: heroku-postgresql:hobby-dev
  #    version: 11
  #    as: DATABASE
  config:
    SUBDOMAIN: "my-app"
    DOMAIN_NAME: "herokuapp.com"
    NODE_ENV: "production"
    TZ: "Europe/Berlin"
    GENERIC_TIMEZONE: "Europe/Berlin"
    N8N_HOST: "${SUBDOMAIN}.${DOMAIN_NAME}"
    N8N_PORT: "${PORT}" #each app in heroku gets randomly assigned IP on start
    N8N_PROTOCOL: "https"
    N8N_ENCRYPTION_KEY: "mysupersecretkey"
    WEBHOOK_TUNNEL_URL: "https://${SUBDOMAIN}.${DOMAIN_NAME}/"
    VUE_APP_URL_BASE_API: "https://${SUBDOMAIN}.${DOMAIN_NAME}/"
    DB_TYPE: "postgresdb"
    DB_POSTGRESDB_HOST: "dbhost"
    DB_POSTGRESDB_DATABASE: "dbname"
    DB_POSTGRESDB_PORT: 5432
    DB_POSTGRESDB_USER: "dbuser"
    DB_POSTGRESDB_PASSWORD: "dbpass"

build:
    docker:
        web: Dockerfile

通过heroku logs --tail记录日志:

2020-04-15T11:19:50.178271+00:00 app[web.1]: [WARN  tini (3)] Tini is not running as PID 1 and isn't registered as a child subreaper.
2020-04-15T11:19:50.178300+00:00 app[web.1]: Zombie processes will not be re-parented to Tini, so zombie reaping won't work.
2020-04-15T11:19:50.178302+00:00 app[web.1]: To fix the problem, use the -s option or set the environment variable TINI_SUBREAPER to register Tini as a child subreaper, or run Tini as PID 1.
2020-04-15T11:19:50.179480+00:00 app[web.1]: su-exec: setgroups: Operation not permitted
2020-04-15T11:24:54.478493+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=my-app.herokuapp.com request_id=myid fwd="myip" dyno= connect= service= status=503 bytes= protocol=https

【问题讨论】:

    标签: node.js heroku heroku-cli


    【解决方案1】:

    su-exec 错误听起来像 n8n 需要 root/提升权限,而您在 Heroku 上没有。如果您必须以某种方式对其进行配置以严格“无特权”运行,请执行此操作。

    【讨论】:

      【解决方案2】:

      您需要稍微修改一下 Dockerfile 和入口点脚本。正如@VxJasonxV 所提到的,su-exec 需要 sudo 权限,这在 Heroku 上是不允许的。

      这是我对容器的实现-

      Heroku yml -

      build:
          docker:
              web: Dockerfile
      

      Dockerfile -

      FROM node:12.16-alpine
      
      # pass N8N_VERSION Argument while building or use default
      ARG N8N_VERSION=0.62.1
      
      # Update everything and install needed dependencies
      RUN apk add --update graphicsmagick tzdata
      
      # Set a custom user to not have n8n run as root
      USER root
      
      # Install n8n and the also temporary all the packages
      # it needs to build it correctly.
      RUN apk --update add --virtual build-dependencies python build-base && \
          npm_config_user=root npm install -g n8n@${N8N_VERSION} && \
          apk del build-dependencies
      
      # Specifying work directory
      WORKDIR /data
      
      # copy start script to container
      COPY ./start.sh /
      
      # make the script executable
      RUN chmod +x /start.sh
      
      # define execution entrypoint
      ENTRYPOINT ["/start.sh"]
      

      入口点脚本

      #!/bin/sh
      
      # check if port variable is set or go with default
      if [ -z ${PORT+x} ]; then echo "PORT variable not defined, leaving N8N to default port."; else export N8N_PORT=$PORT; echo "N8N will start on '$PORT'"; fi
      
      # kickstart nodemation
      n8n
      

      我已经为此创建了一个 Github 存储库,请看一下,我添加了一个描述性很好的自述文件,希望对您有所帮助。 https://github.com/sarveshpro/n8n-heroku

      【讨论】:

        【解决方案3】:

        在 Heroku 上部署 n8n 最简单的方法是去这里:

        https://github.com/UnlyEd/n8n-heroku-demo

        它允许您只需单击按钮即可部署

        【讨论】:

          猜你喜欢
          • 2011-12-18
          • 2014-08-02
          • 2012-08-10
          • 2012-04-29
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多