Giter Club home page Giter Club logo

Comments (14)

rubix28 avatar rubix28 commented on August 16, 2024

The problem is the host IP has changed from 172.17.0.23 to 172.17.0.14.

It seems to me that either the DATABASE_URL variable needs to be automatically updated in this situation, or else the IP needs to be persistent.

from dokku-pg-plugin.

jvanbaarsen avatar jvanbaarsen commented on August 16, 2024

@bluekirby Agree, but i dont think thats something i can configure, right?

from dokku-pg-plugin.

rubix28 avatar rubix28 commented on August 16, 2024

@jvanbaarsen It doesn't seem to be. At a glance it looks like the DATABASE_URL is only updated when a password for the database doesn't already exist (see https://github.com/Kloadut/dokku-pg-plugin/blob/master/commands). Even then, you'd still need to run the create command when the server reboots.

@Kloadut I think the most simple way to fix this is to update the DATABASE_URL environment variable every time the link command is run, but please correct me if I've missed something.

from dokku-pg-plugin.

jvanbaarsen avatar jvanbaarsen commented on August 16, 2024

@bluekirby Can you point me in the direction for the code change? That way i can test it later today on an fork. If it works, i can submit PR

from dokku-pg-plugin.

jvanbaarsen avatar jvanbaarsen commented on August 16, 2024

Related to: dokku/dokku#369

from dokku-pg-plugin.

rubix28 avatar rubix28 commented on August 16, 2024

@jvanbaarsen In https://github.com/Kloadut/dokku-pg-plugin/blob/master/commands, see how the following is nested:

URL="DATABASE_URL=postgres://root:$DB_PASSWORD@$IP/db"
cat "$DOKKU_ROOT/$APP/ENV" | grep "$URL" || echo "export $URL" >> "$DOKKU_ROOT/$APP/ENV"

Changing this won't change the fact that the IP and port provided by docker isn't guaranteed, but it may help prevent a bit of panic when recreating the DB container still appears to fail.

from dokku-pg-plugin.

jvanbaarsen avatar jvanbaarsen commented on August 16, 2024

@bluekirby Are you also using this plugin? If so, how are you dealing with the fact that you cant reboot the server?

If the IP and port is not guaranteed by docker, how can this ever become a stable plugin?

from dokku-pg-plugin.

rubix28 avatar rubix28 commented on August 16, 2024

Yeah, I'm using this plugin at the moment. You can reboot the server, you just have to recreate the postgresql container and update the DATABASE_URL variable manually after you do so (assuming your application is set up to use it, which is recommended).

For me, this translates to:

sudo reboot
dokku postgresql:create database

...
Host: 172.17.0.14
...

dokku config:set app DATABASE_URL=postgres://root:[email protected]/db

Not ideal, but it's working okay for now.

from dokku-pg-plugin.

jvanbaarsen avatar jvanbaarsen commented on August 16, 2024

@bluekirby But when i re-create i wont lose all the data?

from dokku-pg-plugin.

rubix28 avatar rubix28 commented on August 16, 2024

@jvanbaarsen No, the data is persistent. The container doesn't disappear when the server restarts, you just lose your reference to it.

from dokku-pg-plugin.

jvanbaarsen avatar jvanbaarsen commented on August 16, 2024

@bluekirby Ah ok, that will do as a work around (everything is better than using capistrano -_-) Can you also tell me where the PG database is stored? (for backup reasons?)

from dokku-pg-plugin.

rubix28 avatar rubix28 commented on August 16, 2024

You should be able to find it under /var/lib/docker/volumes/

It gets stored under the folder postgresql-appname. Everything will be inside.

(You'll need to be the root user or otherwise have permissions to access this though)

from dokku-pg-plugin.

jvanbaarsen avatar jvanbaarsen commented on August 16, 2024

@bluekirby I've created a hook that will re-map the IP address in the app, but i'm not sure if this should be a hook (since if its gonna be a hook, the dokku team has to accept my PR first: dokku/dokku#397)

Another option is, i create an extra function you can call via this plugin, something like dokku postgresql:relink APPNAME

What do you think?

This is the hook:

#!/bin/bash
APP="$1";
CURRENT_URL=`dokku config:get $APP DATABASE_URL`

dokku postgresql:create $APP
ID=$(docker ps -a | grep "postgresql/$APP":latest |  awk '{print $1}')
IP=$(docker inspect $ID | grep IPAddress | awk '{ print $2 }' | tr -d ',"')
NEW_URL=$(echo $CURRENT_URL | sed -e "s/@.*\//@$IP\//g")
dokku config:set $APP DATABASE_URL=$NEW_URL

from dokku-pg-plugin.

Kloadut avatar Kloadut commented on August 16, 2024

I just fixed the problem by using port instead of local IP, which prevent docker to renew IP at reboot or restart.
Please update the plugin, rebuild the kloadut/postgresql container and the pgsql containers and try again :)

from dokku-pg-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.