You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

借助GitLab CI将Docker镜像部署至Heroku遇dpl问题求助

Hey there! Looks like you're making good progress migrating your .NET Core app from Azure to Heroku, but hitting a snag with the final deployment step using dpl. Let's walk through some solutions to get your CI/CD pipeline over the finish line, either by fixing the dpl issue or switching to the Heroku CLI (which I'll show you how to install in Alpine-based images):

Solutions for Heroku Container Deployment in GitLab CI

Since you've already successfully pushed your Docker image to Heroku's container registry, you only need to run the release step to make the image live. The dpl Heroku provider defaults to Git-based deployment, which doesn't align with your container workflow—this is likely why you're seeing issues.

To install the Heroku CLI in your Alpine-based Docker image, you can use npm (Alpine's apk repo has Node.js packages available). Update your before_script section like this:

before_script:
  - apk update
  - apk add ruby-dev ruby-rdoc nodejs npm
  - gem install dpl # Remove this if you don't plan to use dpl anymore
  - npm install -g heroku

Then replace the final dpl command in your script with the Heroku CLI's container release command:

script:
  - docker build -t aspnetapp -f Dockerfile .
  - docker login --username=$HEROKU_USERNAME --password=$HEROKU_API_KEY registry.heroku.com
  - docker tag aspnetapp registry.heroku.com/[app_name]/web
  - docker push registry.heroku.com/[app_name]/web
  - heroku container:release web -a [app_name] --api-key=$HEROKU_API_KEY

Option 2: Install Heroku CLI via Binary (No Node.js Required)

If you don't want to install Node.js, you can download the Heroku CLI binary directly for Alpine:

before_script:
  - apk update
  - apk add curl tar
  # Download and extract the CLI
  - curl https://cli-assets.heroku.com/heroku-linux-x64.tar.gz -o heroku.tar.gz
  - tar -xvzf heroku.tar.gz -C /usr/local/lib
  # Create a symlink so `heroku` is available in PATH
  - ln -s /usr/local/lib/heroku/bin/heroku /usr/local/bin/heroku
  # Keep your existing Ruby/dpl setup if needed
  - apk add ruby-dev ruby-rdoc
  - gem install dpl

You can then use the same heroku container:release command from Option 1 to finish deployment.

Option 3: Fix dpl for Container Deployment (If You Prefer dpl)

If you want to stick with dpl, you need to use the dedicated heroku-container provider instead of the default Heroku provider (which is for Git deployments). Modify your dpl command to:

- dpl --provider=heroku-container --app=[app_name] --api-key=$HEROKU_API_KEY

Note that the heroku-container provider is less actively maintained than the Heroku CLI, so this might not be as reliable long-term.

As a side note: splitting your pipeline into separate build, push, and deploy stages (like you mentioned you plan to do later) will make debugging issues like this much easier down the line!

内容的提问来源于stack exchange,提问作者Marnus Steyn

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 06:35:52