Skip to content

ThiaudioTT/devdb.sh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 

Repository files navigation

Devdb.sh

Devdb.sh is a simple script in shell to manage development databases. It allows you to easily start, reset, and connect to a local development PostgreSQL database or Redis instance using Docker.

Update and install with:

sudo wget -qO /usr/local/bin/devdb https://github.com/ThiaudioTT/devdb.sh/raw/main/devdb.sh && sudo chmod +x /usr/local/bin/devdb

Now you can simply run:

devdb            # to start or resume the dev database
devdb --reset    # to reset and recreate
devdb --redis    # to start Redis with RedisInsight (port 5540)
devdb --publish  # to bind to 0.0.0.0 and make services accessible from LAN

You can combine flags:

devdb --redis --publish  # Redis accessible from LAN
devdb --reset --publish  # Reset and make accessible from LAN

PostgreSQL

The script will output:

export DATABASE_URL='postgresql://[email protected]:5432/postgres'

Add that line to your shell or .env file to connect.

Redis

When using the --redis flag, the script will output:

export REDIS_URL='redis://127.0.0.1:6379'

Redis features:

  • Redis server on port 6379 (no password)
  • RedisInsight web interface on port 5540
  • Data is automatically wiped and recreated each time you run devdb --redis

Access RedisInsight at: http://127.0.0.1:5540

LAN Access (--publish)

By default, services are bound to 127.0.0.1 (localhost only). Use the --publish flag to bind to 0.0.0.0 and make your development database accessible from other devices on your LAN network.

Examples:

devdb --publish        # PostgreSQL accessible from LAN
devdb --redis --publish # Redis and RedisInsight accessible from LAN

Important

If you have an existing running container and switch between local (127.0.0.1) and LAN (0.0.0.0) access, the script will automatically recreate the container with the correct port bindings. Your data will be preserved for PostgreSQL, but Redis data will be wiped and recreated (this is normal Redis behavior in this script).

Warning

Only use --publish in trusted networks, as it exposes your development database to the entire LAN.

Unpublishing

To revert back to local-only access, simply run the command without the --publish flag:

devdb            # Switch back to localhost only for PostgreSQL
devdb --redis    # Switch back to localhost only for Redis

You can also use the --reset flag to reset and unpublish at the same time:

devdb --reset    # Reset and switch back to localhost only for PostgreSQL
devdb --redis --reset # Reset and switch back to localhost only for Redis

Another alternative is to manually stop and remove the running container.


About

Manage development databases fast and easily

Topics

Resources

Stars

Watchers

Forks

Languages