Skip to content

I put together a proof of concept to get Docker support, what do you think? #204

@nickjj

Description

@nickjj

Hi,

All of my apps are running in Docker and psql is not installed locally. It's often not as easy as installing it through a package manager because your psql client needs to match the server and the server might be running different versions of Postgres depending on the project.

Neovim in this case is running on my work machine and Postgres is running in a container on that machine.

I poked around this plugin and changed references of ['psql'] to ['docker', 'compose', 'exec', 'postgres', 'psql'] where postgres is the name of the service in my compose.yaml file. If the project is up and running with Docker then dadbod is able to run psql in Docker.

That quickly failed saying /tmp/nvim.nick/abc/4 does not exist where abc is a random value which changes every time you open Neovim.

I hacked around that by volume mounting that path into postgres:

    volumes:
      - "postgres:/var/lib/postgresql/data"
      - "/tmp/nvim.nick:/tmp/nvim.nick"

Then it failed for another missing path, to which I also volume mounted:

   volumes:
      - "postgres:/var/lib/postgresql/data"
      - "/tmp/nvim.nick:/tmp/nvim.nick"
      - "/home/nick/.local/share/nvim/dadbod_ui/tmp:/home/nick/.local/share/nvim/dadbod_ui/tmp"

In both cases, if you were to try this, replace nick with your machine's user name.

With that in place, as far as I can tell it's working, complete with linting and auto-complete:

Image

The local modifications I made to the compose.yaml file are in this project https://github.com/nickjj/docker-django-example if you want to use it as a quick example to have a full app running in Docker with Postgres. I didn't commit those up so you'll need to make local edits. The connection string is postgresql://hello:password@localhost:5432/hello.

Needless to say having to volume mount those paths isn't a good long term solution. I'm not well versed in Vimscript but I was wondering if you can do your tpope magic to make it "just work". Perhaps you could expose cmd as an option for the binaries so folks can customize that and then the plugin could be adjusted to not read and write from those tmp and nvim share directories from the same source as where the psql binary was found? Is there a way to make it use the same file system associated with where Neovim is running?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions