pulumi / pulumi-docker

A Docker Pulumi resource package, providing multi-language access to Docker resources and building images.
84 stars 14 forks source link

Split docker host config for remote and local hosts #1266

Open pythoninthegrass opened 2 weeks ago

pythoninthegrass commented 2 weeks ago

This is more of a question. Looking through the docs, I'm not sure if it's possible to split the docker host (DOCKER_HOST) configuration in Pulumi.yml:

name: pulumi_docker
runtime:
  name: python
  options:
    toolchain: poetry
    virtualenv: .venv
    typechecker: mypy
description: Use the docker provider to setup local and remote containers
config:
  docker:host:
    value: unix:///var/run/docker.sock
  docker:host:
    value: ssh://user@remote-host:22
  docker:sshOpts:
    value:
        - -o
        - StrictHostKeyChecking=no
        - -o
        - UserKnownHostsFile=/dev/null
  pulumi:tags:
    value:
      pulumi:template: https://www.pulumi.com/ai/api/project/52d80566-92ad-49af-8b0c-0e5eb4f3d53e.zip

This of course fails as it's a duplicate key

λ pulumi config
error: could not unmarshal '/Users/lance.stephens/git/pulumi_docker/Pulumi.yml': yaml: unmarshal errors:
  line 12: mapping key "docker:host" already defined at line 10

My use case is that I want some containers to be local while others are remote (or both). An example of this workflow is that on the pulumi host (controller?), it needs prometheus, grafana, and the node-exporter for linux. But on remote nodes, certain prometheus exporters will be deployed (e.g., mongo, redis, elasticsearch, etc.)

The business logic can easily handle this, but not sure how pulumi abstracts the underlying terraform and if that's possible without writing separate stacks.

blampe commented 3 days ago

To use multiple hosts you'll want to explicitly configure different remote/local providers and pass those as resource options to the relevant images.

Consider also checking out the new docker-build provider.

pythoninthegrass commented 2 days ago

Appreciate the response! I'll see if I can figure it out and get back to you.