在Heroku上切换到基于Docker的Metabase部署(>=v0.46)

2nc8po8w  于 2023-06-23  发布在  Docker
关注(0)|答案(1)|浏览(154)

由于Metabase在v0.45版本中不支持Heroku,metabase-deploy工作流不再升级到最新版本。
展望未来,我们似乎需要在Heroku上使用基于Docker的部署,但Upgrading Metabase页面没有提供任何关于如何从之前的部署方法切换的说明。有人能给我们指明正确的方向吗?

z31licg0

z31licg01#

通过创建post中提到的两个文件,我能够运行Metabase容器。首先,我下载了Heroku repo,然后用这些文件替换了这些文件:
Dockerfile

FROM metabase/metabase:v0.46.5

COPY docker-entrypoint.sh /app/

RUN ["chmod", "+x", "/app/docker-entrypoint.sh"]

ENTRYPOINT [ "/app/docker-entrypoint.sh" ]

docker-entrypoint.sh

#!/usr/bin/env bash

if [ "$PORT" ]; then
    export MB_JETTY_PORT="$PORT"
fi

if [ "$DATABASE_URL" ]; then
    export MB_DB_CONNECTION_URI="$DATABASE_URL"
fi

# We need to override the $JAVA_OPTS and give it a slightly lower memory limit
# because Heroku tends to think we can use more memory than we actually can.
JAVA_OPTS="$JAVA_OPTS -XX:+UnlockExperimentalVMOptions"
JAVA_OPTS+=" -XX:+UseContainerSupport"         # Tell the JVM to use container info to set heap limit -- see https://devcenter.heroku.com/articles/java-memory-issues#configuring-java-to-run-in-a-container
JAVA_OPTS+=" -XX:-UseGCOverheadLimit"          # Disable limit to amount of time spent in GC. Better slow than not working at all
JAVA_OPTS+=" -XX:+UseCompressedOops"           # Use 32-bit pointers. Reduces memory usage
JAVA_OPTS+=" -XX:+UseCompressedClassPointers"  # Same as above. See also http://blog.leneghan.com/2012/03/reducing-java-memory-usage-and-garbage.html
JAVA_OPTS+=" -Xverify:none"                    # Skip bytecode verification, the Heroku buildpack comes from us so it's already verified. Speed up launch slightly
JAVA_OPTS+=" -XX:+UseG1GC"                     # G1GC seems to use slightly less memory in my testing...
JAVA_OPTS+=" -XX:+UseStringDeduplication"      # Especially when used in combination with string deduplication

# Other Java options
JAVA_OPTS+=" -server"                  # Run in server mode. This is the default for 64-bit JVM
JAVA_OPTS+=" -Djava.awt.headless=true" # don't try to start AWT. Not sure this does anything but better safe than wasting memory
JAVA_OPTS+=" -Dfile.encoding=UTF-8"    # Use UTF-8

# Set timezone using the JAVA_TIMEZONE variable if present
if [ "$JAVA_TIMEZONE"]; then
    echo "  -> Timezone setting detected: $JAVA_TIMEZONE"
    JAVA_OPTS+=" -Duser.timezone=$JAVA_TIMEZONE"
fi

echo "JAVA_OPTS: $JAVA_OPTS"
export JAVA_OPTS

/app/run_metabase.sh

我备份了数据库,然后运行了以下命令:

heroku container:login
heroku container:push web
heroku container:release web

确保设置了DATABASE_URL环境变量。我需要让Metabase在小于1GB的RAM上运行,因此我还设置了一个JAVA_OPTS环境变量,值为-Xms640m -Xmx640m

相关问题