Images cannot connect to Azure DBs
- Dominant language
- Shell
- Stars
- 35
- Forks
- 41
- PR merge metrics
- No merged PRs in 30d
Description
Hello all!
I have been testing and trying this images for a deployment in Azure. However, I'm facing problems when trying to connect the instance to the Azure DB.
## Steps to reproduce
1. Create an Azure Postgresql Database
a. usually something like: `postgresql://:@.database.azure.com/?sslmode=require`
3. Set the `sqlalchemy.url` to point to the database.
4. Run the instance
You will get an error when trying to start the application. (it will fail the first time trying to connect to the database)
```
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "nrc-postgresql.postgres.database.azure.com" (172.178.55.110), port 5432 failed: could not open certificate file "/root/.postgresql/postgresql.crt": Permission denied
```
## Mode details
After debugging for quite some hours I think the error comes from `uWSGI` (although it points to an issue reading with a certificate).
Why I think this is the case? First, if I login into the container and run `ckan shell` I can access the database. If I replace the `start_ckan.sh` with a call to start CKAN using `gunicorn` it will work.
This works:
```dockerfile
FROM ckan/ckan-base:2.10.1
# Just to setup the configuration file with the DB connection
# SQLALCHEMY_URL = `postgresql://:@.database.azure.com/?sslmode=require`
ARG SQLALCHEMY_URL
COPY setup-configuration-file.sh .
RUN ./setup-configuration-file.sh
RUN pip install gunicorn
CMD ["gunicorn", "--workers", "2", "--bind", "0.0.0.0:5000", "wsgi:application"]
```
This doesn't work:
```dockerfile
FROM ckan/ckan-base:2.10.1
# Just to setup the configuration file with the DB connection
# SQLALCHEMY_URL = `postgresql://:@.database.azure.com/?sslmode=require`
ARG SQLALCHEMY_URL
COPY setup-configuration-file.sh .
RUN ./setup-configuration-file.sh
# Default to CMD ["/srv/app/start_ckan.sh"]
```
Any ideas or someone else has encountered this error?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by comparing the default start_ckan.sh/uWSGI path with the working gunicorn command, using the two Dockerfile examples and the SQLALCHEMY_URL configuration. Reproduce the Azure PostgreSQL connection failure and inspect where the certificate permission error is introduced. Done means the default CKAN image startup connects successfully to Azure PostgreSQL without replacing its startup command.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, docker, postgresql, shell
- Domain
- cloud, databases, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100