Hi
I am trying to setup integration testing and wondering if there is a way to restore .sql dump file onto the test database, using postgres service. Ideally, I would like to use the tools that come with the service (pg_restore) and not install them on my base image.
Is this even possible?
Thanks in advance!
Hi Olaf and welcome to the community!
When you use a service for postgres, a Docker container starts based on the image you have specified for the service, and that container shares a network adapter with your build container. PostgreSQL will be available on localhost:5432. More info on service containers:
The commands of that step in your bitbucket-pipelines.yml file are executed in the build container (not in the service container), so any tools you want to use need to be installed in the build container. If you want to use pg_restore, then I believe you'll need the postgresql-client in the build container.
You can either install the client during the build, or you can create your own custom Docker image that has the postgresql-client and any other tools you want to use, and then use that Docker image as a build container. We have more resources on creating your own Docker image here:
Please feel free to reach out if you have any questions.
Kind regards,
Theodora
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.