Deploy Heroku Docker Api (.net core 6 ) image with PostgreSQL - postgresql

There is postgres Add-ons in Heroku which I want to connect it to my Docker image of my Api with connection string:
_connectionString = Environment.GetEnvironmentVariable("POSTGRESQL_CONNECTION_STRING");
how I can define Environment Variable in postgres to connect [postgres database in Herkou] to my Api docker image?(my api is in .core 6)

Related

Deploying Hasura on container app with existing Postgresql Flexible Server

How can be deploy Hasura on Container App with postgresql Flexible Server using dockerfile or docker compose.

"Invalid Credentials" when connecting Terraform to PostgreSQL State Backend

Objective
I'm trying to configure Hashicorp Terraform to utilize a PostgreSQL database as the state storage backend. I'm running Terraform version 1.3.3 on Ubuntu Studio 64-bit, and also have Docker Engine installed locally.
Repro Steps
Spin up Postgres with Docker docker run --detach --net=host --env POSTGRES_PASSWORD=xxxxx postgres
Exec into container and create database with psql: docker exec -it <containerID> psql --user=postgres
Configure Terraform backend, as shown below
Run terraform init command
terraform {
backend "pg" {
conn_str = "postgres://xxxxxxxxxx:xxxxxx#localhost/terraform_remote_state?sslmode=disable"
}
}
Actual Result
The pq library for Golang is throwing an error saying "Invalid Credentials."
I am able to use database clients, like psql or DBeaver Community Edition to connect to the database server.
Is the Postgres driver for Terraform simply broken? How can I get it to authenticate properly?

Keycloak container not able to connect to external database

I am trying to connect keycloak docker image quay.io/keycloak/keycloak:19.0.2 to Azure managed postgres database instance.
Reason: Our main application db is on azure so it's preferrable for us to point keycloak to same database.
We already tried and tested the keycloak functionality using standalone linux installation (./bin/kc.sh) which easily connected to azure postgres database and all our realms and user, client configuration is set into this azure postgres database.
Command: docker run --env-file endpoint.txt -p 8080:8080 quay.io/keycloak/keycloak:19.0.2 start-dev
Contents in endpoint.txt file:
DB_VENDOR=postgres
DB_ADDR=Azure_postgres_url
DB_PORT=5432
DB_DATABASE=keycloak_database
DB_USER=user
DB_PASSWORD=password
Behaviour:
http://public_ip:8080/
Keycloak landing page shows but it's not connected to existing azure db, we have to set admin account , realms and user configurations from scratch.
Mostly keycloak is using it's internal database (H2)
Your help is appreciated. Thanks for your time.

Docker Gitlab Runner Running Flyway Unable to Obtain Connection with AWS Postgres RDS

The Problem: I am unable to connect to a Postgres RDS from a Gitlab runner via Flyway.
The Error:
ERROR: Unable to obtain connection from database (jdbc:postgresql://datacatalog-rds-stage.redacted.us-west-2.rds.amazonaws.com:5432/datacatalog
) for user 'dos': FATAL: database "datacatalog
" does not exist
What I have tried:
Verified I can connect locally. I am able to connect using the same credentials and jdbc url from a docker container on my desktop
Confirmed that the private IP address the Gitlab runner could be on, is in a source range, in the RDS security group inbound rules
Any help you can provide would be greatly appreciated.
Thanks!

Applying Entity Framework Core's Database Update to PostgreSQL server on a docker container with SSH

I'm a bit new to SQL and Docker. I've recently created a container for PostgreSQL on my Linux server that can be accessed by SSH. I am trying to manage it using the Entity Framework on .NET Core 2.2.
I'm trying to go by Npgsql's official documentation, but there isn't any provision for connection via SSH. The example they've provided for the connection string is:
optionsBuilder.UseNpgsql("Host=my_host;Database=my_db;Username=my_user;Password=my_pw")
Where:
my_host is set to the docker container's IP address.
my_db is the database name
my_user is the username on PostgreSQL
my_pw is the database password
I am also using this First EF Core Console Application as a tutorial. When I am attempting on the dotnet CLI:
dotnet ef database update
It keeps timing out, obviously because it can't connect to the server via SSH.
I've done my fair share of Googling with no luck. Can any of you please advise?
Edit FYI:
I am using a Windows 10 computer as a client
I am using Ubuntu Linux and connecting via OpenSSH
The Linux server has a Docker Container w/ PostgreSQL
I have successfully connected from my Windows 10 client using DBeaver
In principle, connecting to PostgreSQL isn't done over SSH - it's done directly via port 5432. You typically need to configure your container to expose that port (check the docker networking docs).
It is possible to use SSH tunneling to connect to PG (or any other service), but that's a pretty specialized mechanism to bypass firewalls and the like. You likely just need to expose port 5432 from your container.