Use latest version of Docker image for app platform -> deploy latest using Terraform

Hi guys … I’m using Terraform to deploy to the DigitalOcean App platform which basically works good. I’m deploying a public image from DockerHub.

This is my config.

resource "digitalocean_app" "docs-page" {
  spec {
    domain {
      name = "${var.do_subdomain_docs}.${var.do_base_domain}"
    name   = "docs-page"
    region = var.do_region

    service {
      name               = "docs-page-app"
      http_port          = 80
      instance_count     = 1
      instance_size_slug = var.do_instance_smallest
      internal_ports     = []
      source_dir         = "/"

      image {
        registry_type = "DOCKER_HUB"
        registry      = "sommerfeldio"
        repository    = "docs-website"
        tag           = "stable"

      routes {
        path                 = "/"
        preserve_path_prefix = false

The image of choice is my sommerfeldio/docs-website:stable (docker pull sommerfeldio/docs-website:stable).

My problem is this: I deploy a new version of my image to DockerHub. Then I trigger terraform apply to update my DigitalOcean infrastructure and terraform states, that nothing has changed (“Apply complete! Resources: 0 added, 0 changed, 0 destroyed.”). This might be true from an infrastructure-pount-of-view because there is no chagne to e.g. the instances count or domain name or whatever. But my image did change. And this change is not picked up. To update my DigitalOcean app I have to destroy and re-provision everything. Which is not something I wanna do.

I’m using this provider:

How can I tell the terraform-digitalocean-provider to (1) re-deploy the app with the latest image version from DockerHub or (2) update my above mentioned config in a way that it is mandatory to load the image from DockerHub all the time?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
October 9, 2022

Hi there,

There are two suggestions that come to my mind:

  • If you were to use the DigitalOcean Container Registry rather than Docker Hub, you will be able to enable automatic deployments, so that whenever you push a new image to that tag, the App Platform will automatically deploy it without you having to do any extra actions:

  • Alternatively, you could use the doctl CLI tool, to trigger a new forced rebuild, that way you would not have to re-provision everything each time.

If you want to force a rebuild you can do so with doctl, DigitalOcean’s command-line utility.

First, find the app’s ID with doctl app list, and then create a new deployment with the --force-rebuild option. Ex. doctl app create-deployment --force-rebuild 42a33f83-5093-44c7-acb5-53f0a218b732.

Hope that this helps!



Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel
Get started for free

Enter your email to get $200 in credit for your first 60 days with DigitalOcean.

New accounts only. By submitting your email you agree to our Privacy Policy.

© 2023 DigitalOcean, LLC.