Basic Database example (not ruby)

There is a basic database example in the docs, https://circleci.com/docs/2.0/postgres-config/, but it’s all ruby, and while I can kind of infer what’s going on, I’m not sure how to translate to a more generic set up.

I’m trying to instantiate a postgres database to use with a Symfony app. I have a schema that I want to import and to connect to the symfony app.

But, psql isn’t in the path, and docker doesn’t run, so I can’t connect using the docker network. Any more basic v2.0 examples?

This 5 minute video will probably help you understand a bit more. It’s a super simple example using postgres and psql. If there’s any tools missing in the Docker images you can customize the images to include what you need.

Thanks Fern. This is helpful, but I think what I’m really looking for is a Symfony example in version 2.0.

Oh, Also, I keep running into problems installing the postgres client.

dpkg: dependency problems prevent configuration of postgresql-client:
 postgresql-client depends on postgresql-client-9.6; however:
  Package postgresql-client-9.6 is not configured yet.

I’m starting to wonder if this is an issue with the php image I’m pulling down. Using the circleci/python:3.6.2-stretch-browsers image and I can connect to the postgres db, but using circleci/php:7.1-cli-node-browsers the same connection doesn’t work.
I’m not sure how these would be different

Did you try installing postgresql-client-9.6 first? I don’t have a whole lot of experience with Symfony so i’m in the boat with a single paddle here. Searching around on GitHub I did see some example projects I think. This project here looks like a Symfony boilerplate that’s already configured to run on CircleCI 2.0. You might be able to draw some insights from it.

There’s two approaches:

  • Use a primary build container and a secondary PostgreSQL container (your current approach)
  • Install PostgreSQL server in your build container from the distro repo

Either is good really, and what you’ll prefer probably comes down to what is fastest. I’d wager there is not much in it.

If you are happy to go for the second option, then installing the database server on the build container will give you everything you need to connect. You then just need to install php-pgsql. I have shown how to do something similar with MySQL here.

thanks halfer. I was looking at both these approaches. The “just install php-pgsql”(that’s what I thought too), turns out to be a lot harder than expected, for one the php postgres module needs to be installed and enabled.

This was a good start, thanks. I’m having other issues, but I think they deserve a different thread. This ended up getting me moving:

      - run: sudo apt-get update
      - run: sudo apt-get install libpq-dev
      - run: sudo docker-php-ext-install pdo_pgsql

Oh, I looked closer, thanks for the link that’s good stuff.

Sounds like you’re close!

In general, the extension should not need manual enablement in an ini file - installing pdo_pgsql should write a child ini file automatically to turn it on, at least in Ubuntu. You can always put a php -i in your build process after the installation, to see if it was successful.

By the way, if you get it working, please do add your config here - perhaps I can create a new PHP demo for PostgreSQL.

1 Like

It looks like there’s a configuration error that’s coming all the way from Debian. I don’t know when it will come down to ubuntu, so I needed to find another solution.
Wrapping the command in a shell script turned out to work. The client tools are available, and the config error dies a quiet death. Run all test steps even if one fails Run all test steps even if one fails

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.