Merge pull request #159 from shipyardbuild/fix-postgres-init
Set an explicit username and password for the db service
This commit is contained in:
		| @@ -41,6 +41,9 @@ services: | |||||||
|   db: |   db: | ||||||
|     image: postgres:9.4 |     image: postgres:9.4 | ||||||
|     container_name: db |     container_name: db | ||||||
|  |     environment: | ||||||
|  |       POSTGRES_USER: "postgres" | ||||||
|  |       POSTGRES_PASSWORD: "postgres" | ||||||
|     volumes: |     volumes: | ||||||
|       - "db-data:/var/lib/postgresql/data" |       - "db-data:/var/lib/postgresql/data" | ||||||
|     networks: |     networks: | ||||||
|   | |||||||
| @@ -7,6 +7,9 @@ services: | |||||||
|       - "6379:6379" |       - "6379:6379" | ||||||
|   db: |   db: | ||||||
|     image: postgres:9.4 |     image: postgres:9.4 | ||||||
|  |     environment: | ||||||
|  |       POSTGRES_USER: "postgres" | ||||||
|  |       POSTGRES_PASSWORD: "postgres" | ||||||
|     ports: |     ports: | ||||||
|       - "5432:5432" |       - "5432:5432" | ||||||
|   vote: |   vote: | ||||||
|   | |||||||
| @@ -18,6 +18,9 @@ services: | |||||||
|  |  | ||||||
|   db: |   db: | ||||||
|     image: postgres:9.4 |     image: postgres:9.4 | ||||||
|  |     environment: | ||||||
|  |       POSTGRES_USER: "postgres" | ||||||
|  |       POSTGRES_PASSWORD: "postgres" | ||||||
|  |  | ||||||
|   result: |   result: | ||||||
|     build: ./result |     build: ./result | ||||||
|   | |||||||
| @@ -43,6 +43,9 @@ services: | |||||||
|   db: |   db: | ||||||
|     image: postgres:9.4 |     image: postgres:9.4 | ||||||
|     container_name: db |     container_name: db | ||||||
|  |     environment: | ||||||
|  |       POSTGRES_USER: "postgres" | ||||||
|  |       POSTGRES_PASSWORD: "postgres" | ||||||
|     volumes: |     volumes: | ||||||
|       - "db-data:/var/lib/postgresql/data" |       - "db-data:/var/lib/postgresql/data" | ||||||
|     networks: |     networks: | ||||||
|   | |||||||
| @@ -16,6 +16,9 @@ services: | |||||||
|         condition: on-failure |         condition: on-failure | ||||||
|   db: |   db: | ||||||
|     image: postgres:9.4 |     image: postgres:9.4 | ||||||
|  |     environment: | ||||||
|  |       POSTGRES_USER: "postgres" | ||||||
|  |       POSTGRES_PASSWORD: "postgres" | ||||||
|     volumes: |     volumes: | ||||||
|       - db-data:/var/lib/postgresql/data |       - db-data:/var/lib/postgresql/data | ||||||
|     networks: |     networks: | ||||||
|   | |||||||
| @@ -14,6 +14,9 @@ services: | |||||||
|         condition: on-failure |         condition: on-failure | ||||||
|   db: |   db: | ||||||
|     image: postgres:9.4 |     image: postgres:9.4 | ||||||
|  |     environment: | ||||||
|  |       POSTGRES_USER: "postgres" | ||||||
|  |       POSTGRES_PASSWORD: "postgres" | ||||||
|     volumes: |     volumes: | ||||||
|       - db-data:/var/lib/postgresql/data |       - db-data:/var/lib/postgresql/data | ||||||
|     networks: |     networks: | ||||||
|   | |||||||
| @@ -18,6 +18,11 @@ spec: | |||||||
|       containers: |       containers: | ||||||
|       - image: postgres:9.4 |       - image: postgres:9.4 | ||||||
|         name: postgres |         name: postgres | ||||||
|  |         env: | ||||||
|  |         - name: POSTGRES_USER | ||||||
|  |           value: postgres | ||||||
|  |         - name: POSTGRES_PASSWORD | ||||||
|  |           value: postgres | ||||||
|         ports: |         ports: | ||||||
|         - containerPort: 5432 |         - containerPort: 5432 | ||||||
|           name: postgres |           name: postgres | ||||||
|   | |||||||
| @@ -77,6 +77,10 @@ spec: | |||||||
|         env: |         env: | ||||||
|         - name: PGDATA |         - name: PGDATA | ||||||
|           value: /var/lib/postgresql/data/pgdata |           value: /var/lib/postgresql/data/pgdata | ||||||
|  |         - name: POSTGRES_USER | ||||||
|  |           value: postgres | ||||||
|  |         - name: POSTGRES_PASSWORD | ||||||
|  |           value: postgres | ||||||
|         ports: |         ports: | ||||||
|         - containerPort: 5432 |         - containerPort: 5432 | ||||||
|           name: db |           name: db | ||||||
|   | |||||||
| @@ -47,6 +47,9 @@ services: | |||||||
|  |  | ||||||
|   db: |   db: | ||||||
|     image: postgres:9.4 |     image: postgres:9.4 | ||||||
|  |     environment: | ||||||
|  |       POSTGRES_USER: "postgres" | ||||||
|  |       POSTGRES_PASSWORD: "postgres" | ||||||
|     volumes: |     volumes: | ||||||
|       - "db-data:/var/lib/postgresql/data" |       - "db-data:/var/lib/postgresql/data" | ||||||
|     networks: |     networks: | ||||||
|   | |||||||
| @@ -24,7 +24,7 @@ io.sockets.on('connection', function (socket) { | |||||||
| }); | }); | ||||||
|  |  | ||||||
| var pool = new pg.Pool({ | var pool = new pg.Pool({ | ||||||
|   connectionString: 'postgres://postgres@db/postgres' |   connectionString: 'postgres://postgres:postgres@db/postgres' | ||||||
| }); | }); | ||||||
|  |  | ||||||
| async.retry( | async.retry( | ||||||
|   | |||||||
| @@ -16,7 +16,7 @@ namespace Worker | |||||||
|         { |         { | ||||||
|             try |             try | ||||||
|             { |             { | ||||||
|                 var pgsql = OpenDbConnection("Server=db;Username=postgres;"); |                 var pgsql = OpenDbConnection("Server=db;Username=postgres;Password=postgres;"); | ||||||
|                 var redisConn = OpenRedisConnection("redis"); |                 var redisConn = OpenRedisConnection("redis"); | ||||||
|                 var redis = redisConn.GetDatabase(); |                 var redis = redisConn.GetDatabase(); | ||||||
|  |  | ||||||
| @@ -46,7 +46,7 @@ namespace Worker | |||||||
|                         if (!pgsql.State.Equals(System.Data.ConnectionState.Open)) |                         if (!pgsql.State.Equals(System.Data.ConnectionState.Open)) | ||||||
|                         { |                         { | ||||||
|                             Console.WriteLine("Reconnecting DB"); |                             Console.WriteLine("Reconnecting DB"); | ||||||
|                             pgsql = OpenDbConnection("Server=db;Username=postgres;"); |                             pgsql = OpenDbConnection("Server=db;Username=postgres;Password=postgres;"); | ||||||
|                         } |                         } | ||||||
|                         else |                         else | ||||||
|                         { // Normal +1 vote requested |                         { // Normal +1 vote requested | ||||||
|   | |||||||
| @@ -72,7 +72,7 @@ class Worker { | |||||||
|  |  | ||||||
|       while (conn == null) { |       while (conn == null) { | ||||||
|         try { |         try { | ||||||
|           conn = DriverManager.getConnection(url, "postgres", ""); |           conn = DriverManager.getConnection(url, "postgres", "postgres"); | ||||||
|         } catch (SQLException e) { |         } catch (SQLException e) { | ||||||
|           System.err.println("Waiting for db"); |           System.err.println("Waiting for db"); | ||||||
|           sleep(1000); |           sleep(1000); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jenny Burcio
					Jenny Burcio