Skip to content

Commit a8888af

Browse files
author
Peter Valdez
committedFeb 16, 2020
Set an explicit username and password for the db service
1 parent 2209b3a commit a8888af

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed
 

‎docker-compose.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ services:
4343
db:
4444
image: postgres:9.4
4545
container_name: db
46+
environment:
47+
POSTGRES_USER: "postgres"
48+
POSTGRES_PASSWORD: "postgres"
4649
volumes:
4750
- "db-data:/var/lib/postgresql/data"
4851
networks:
@@ -53,4 +56,4 @@ volumes:
5356

5457
networks:
5558
front-tier:
56-
back-tier:
59+
back-tier:

‎result/server.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ io.sockets.on('connection', function (socket) {
2424
});
2525

2626
var pool = new pg.Pool({
27-
connectionString: 'postgres://postgres@db/postgres'
27+
connectionString: 'postgres://postgres:postgres@db/postgres'
2828
});
2929

3030
async.retry(

‎worker/src/Worker/Program.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static int Main(string[] args)
1616
{
1717
try
1818
{
19-
var pgsql = OpenDbConnection("Server=db;Username=postgres;");
19+
var pgsql = OpenDbConnection("Server=db;Username=postgres;Password=postgres;");
2020
var redisConn = OpenRedisConnection("redis");
2121
var redis = redisConn.GetDatabase();
2222

@@ -46,7 +46,7 @@ public static int Main(string[] args)
4646
if (!pgsql.State.Equals(System.Data.ConnectionState.Open))
4747
{
4848
Console.WriteLine("Reconnecting DB");
49-
pgsql = OpenDbConnection("Server=db;Username=postgres;");
49+
pgsql = OpenDbConnection("Server=db;Username=postgres;Password=postgres;");
5050
}
5151
else
5252
{ // Normal +1 vote requested

‎worker/src/main/java/worker/Worker.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static Connection connectToDB(String host) throws SQLException {
7272

7373
while (conn == null) {
7474
try {
75-
conn = DriverManager.getConnection(url, "postgres", "");
75+
conn = DriverManager.getConnection(url, "postgres", "postgres");
7676
} catch (SQLException e) {
7777
System.err.println("Waiting for db");
7878
sleep(1000);

0 commit comments

Comments
 (0)