Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restart container on config change #27

Open
zimbatm opened this issue Mar 23, 2022 · 0 comments
Open

Restart container on config change #27

zimbatm opened this issue Mar 23, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@zimbatm
Copy link
Member

zimbatm commented Mar 23, 2022

Is your feature request related to a problem? Please describe.

Let's say I have a config file on the host, and a docker container that loads it. If the config file gets updated, the container isn't notified of the change. Eg:

resource "linuxbox_text_file" "caddy_config" {
  ssh_user     = local.ssh_user
  ssh_key      = local.ssh_key
  host_address = local.host_address

  path  = "/home/ubuntu/Caddyfile"
  content = <<-CADDYFILE
  # Caddy config here
  CADDYFILE
  owner = 1000
  group = 1000
  mode  = 644
}

resource "linuxbox_docker_container" "caddy" {
  depends_on = [
    linuxbox_text_file.caddy_config,
  ]

  ssh_user     = local.ssh_user
  ssh_key      = local.ssh_key
  host_address = local.host_address

  image_id = "caddy:2.4.6-alpine"
  name     = "caddy"
  restart  = "unless-stopped"

  ports = [
    "80:80",
    "443:443",
  ]

  volumes = [
    "/home/ubuntu/Caddyfile:/etc/caddy/Caddyfile",
  ]
}

Describe the solution you'd like

Add a triggers section in the linuxbox_docker_container resource that works like the null_resource. Whenever the trigger values change, it forces the recreation of the resource, restarting the container in the process.

Describe alternatives you've considered

A null resource could be used to trigger a restart.

Potentially add a trigger_action that can be set to "reload" for containers that support soft-reloads.

Additional context

@zimbatm zimbatm added the enhancement New feature or request label Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant