5

I'm struggling to configure the MAX_CONNECTIONS postgres config in my circleCI configuration file. As you can see below I tried using sed to replace the max_connections value, but this didn't do anything, the max_connections remained at the default 100. I also tried to run a custom command (see the commented command: | block below), but this threw the following error and stopped the circleCI process: /docker-entrypoint.sh: line 100: exec: docker: not found Exited with code 127

version: 2
jobs:
  test:
    pre:
      - sudo sed -i 's/max_connections = 100/max_connections = 300/g' /etc/postgresql/9.6/main/postgresql.conf # Allow more than 100 connections to DB
      - sudo service postgresql restart
    docker:
      # Specify the version you desire here
      - image: circleci/node:8.11
      # Setup postgres and configure the db
      - image: hegand/postgres-postgis
        # command: |
        #   docker run --name hegand/postgres-postgis -e POSTGRES_PORT=$POSTGRES_PORT POSTGRES_PASSWORD=$POSTGRES_PASSWORD POSTGRES_DB=$POSTGRES_DB -d postgres -N 300
        environment:
          POSTGRES_USER: user
          POSTGRES_DB: table
          POSTGRES_PASSWORD: ""
          POSTGRES_PORT: 5432
James111
  • 15,378
  • 15
  • 78
  • 121
  • 2
    @wwerner's answer might be the way to go. keep in mind though that `pre` isn't a section in CircleCI 2.0 config. Those commands won't run. – FelicianoTech Oct 22 '18 at 15:14

2 Answers2

2

Specifying the command within -image is the right way to go. You just have to use the command to start the docker container but the one that is run inside the container, i.e. instead of the value of CMD in the dockerfile.

I think that the following should work:

- image: hegand/postgres-postgis
    command: postgres -c max_connections=300

Have a look at the CircleCI config reference: https://circleci.com/docs/2.0/configuration-reference/#docker

wwerner
  • 4,227
  • 1
  • 21
  • 39
0

Following Adrian Mouat's answer, you can pass all config changes in command option in docker-compose file, it is is so clean & simple to generate for different environments.

services:
  postgres:
    ...  
    image: postgres:11.5
    command:
      - "postgres"
      - "-c"
      - "max_connections=1000"
      - "-c"
      - "shared_buffers=3GB"
      - "-c"
      ...
V-Q-A NGUYEN
  • 1,497
  • 16
  • 19