Skip to content

Commit

Permalink
Set an explicit username and password for the db service
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Valdez committed Feb 16, 2020
1 parent 2209b3a commit a8888af
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ services:
db:
image: postgres:9.4
container_name: db
environment:
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "postgres"
volumes:
- "db-data:/var/lib/postgresql/data"
networks:
Expand All @@ -53,4 +56,4 @@ volumes:

networks:
front-tier:
back-tier:
back-tier:
2 changes: 1 addition & 1 deletion result/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ io.sockets.on('connection', function (socket) {
});

var pool = new pg.Pool({
connectionString: 'postgres://postgres@db/postgres'
connectionString: 'postgres://postgres:postgres@db/postgres'
});

async.retry(
Expand Down
4 changes: 2 additions & 2 deletions worker/src/Worker/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static int Main(string[] args)
{
try
{
var pgsql = OpenDbConnection("Server=db;Username=postgres;");
var pgsql = OpenDbConnection("Server=db;Username=postgres;Password=postgres;");
var redisConn = OpenRedisConnection("redis");
var redis = redisConn.GetDatabase();

Expand Down Expand Up @@ -46,7 +46,7 @@ public static int Main(string[] args)
if (!pgsql.State.Equals(System.Data.ConnectionState.Open))
{
Console.WriteLine("Reconnecting DB");
pgsql = OpenDbConnection("Server=db;Username=postgres;");
pgsql = OpenDbConnection("Server=db;Username=postgres;Password=postgres;");
}
else
{ // Normal +1 vote requested
Expand Down
2 changes: 1 addition & 1 deletion worker/src/main/java/worker/Worker.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static Connection connectToDB(String host) throws SQLException {

while (conn == null) {
try {
conn = DriverManager.getConnection(url, "postgres", "");
conn = DriverManager.getConnection(url, "postgres", "postgres");
} catch (SQLException e) {
System.err.println("Waiting for db");
sleep(1000);
Expand Down

0 comments on commit a8888af

Please sign in to comment.