-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
expose postgresql so that it can be accessed outside of Docker #4269
Comments
The root of the problem here is that we're defaulting to using SQLite. We need to update a few things. Firstly, we need to update docker-compose.yml: In the environment:
- POSTGRES_USER=foundationsite
- POSTGRES_PASSWORD=devmode
- POSTGRES_DB=foundationsite This will, upon DB creation, add We'll need to update the default connection string in |
helpful reference: https://hub.docker.com/_/postgres Scroll down to "Environment Variables" |
turns out the ports are |
PR filed, it changes with open(env_file, 'r') as f:
env_vars = f.read()
# We need to strip the quotes because Docker-compose considers them as part of the env value.
env_vars = env_vars.replace('"', '')
# We also need to make sure to use the correct db values based on our docker settings.
username = password = dbname = 'postgres'
with open('docker-compose.yml', 'r') as d:
docker_compose = d.read()
username = re.search('POSTGRES_USER=(.*)', docker_compose).group(1) or username
password = re.search('POSTGRES_PASSWORD=(.*)', docker_compose).group(1) or password
dbname = re.search('POSTGRES_DB=(.*)', docker_compose).group(1) or dbname
# Update the DATABASE_URL env
new_db_url = f"DATABASE_URL=postgresql://{username}:{password}@postgres:5432/{dbname}"
old_db_url = re.search('DATABASE_URL=.*', env_vars)
env_vars = env_vars.replace(old_db_url.group(0), new_db_url) |
This is especially important for database issues relating to real data, such as deleting user accounts from the prod/staging instances.
The text was updated successfully, but these errors were encountered: