dreamfactorysoftware / df-docker

Docker container for DreamFactory.
59 stars 56 forks source link

Fix for Postgres support #37

Closed davidsackett closed 7 years ago

davidsackett commented 7 years ago

Using df-docker to deploy DF with Postgres does not appear to work currently.

Setting DB_DRIVER to a value other than mysql (e.g. pgsql) does not appear to work. This seems to be because the DB_HOST statement contains a specific reference to mysql. Moving the DB_DRIVER statement above the DB_HOST statement has the desired behaviour. I've not modified the DB_HOST because I could unexpectedly impact the current behaviour.

Adding support for setting DB_PORT was also required as Postgres uses port 5432 rather than MySQL's 3306

This fix should work for other databases too however I've only tested it with Postgres and MySQL.

Below is an example docker-compose.yml file for a Postgres deployment:

version: '2'
services:
  web:
    environment:
      SERVERNAME: dreamfactory.local
      DB_HOST: pgsql
      DB_DRIVER: pgsql
      DB_USERNAME: df_admin
      DB_PASSWORD: df_admin
      DB_DATABASE: dreamfactory
      DB_PORT: 5432
      REDIS_HOST: redis
      REDIS_DATABASE: 0
      REDIS_PORT: 6379
      APP_KEY: ASDFIOWEQFASDKFASDFLJASDFJDKTWPG
    volumes:
      - df-storage:/opt/dreamfactory/storage
    build: .

  load-balancer:
    image: dockercloud/haproxy
    links:
        - web
    volumes:
        - /var/run/docker.sock:/var/run/docker.sock
    environment:
      BALANCE: roundrobin
    ports:
        - "80:80"
  pgsql:
    environment:
      POSTGRES_DB: dreamfactory
      POSTGRES_USER: df_admin
      POSTGRES_PASSWORD: df_admin
    image: postgres

  redis:
    image: redis

volumes:
  df-storage:
    driver: local