https://github.com/thiaudiott/devdb.sh
Manage development databases fast and easily
https://github.com/thiaudiott/devdb.sh
docker shell
Last synced: about 2 months ago
JSON representation
Manage development databases fast and easily
- Host: GitHub
- URL: https://github.com/thiaudiott/devdb.sh
- Owner: ThiaudioTT
- Created: 2025-07-04T15:53:33.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-07-04T16:15:12.000Z (12 months ago)
- Last Synced: 2025-07-04T17:19:19.271Z (12 months ago)
- Topics: docker, shell
- Language: Shell
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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:
```bash
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:
```bash
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:
```bash
devdb --redis --publish # Redis accessible from LAN
devdb --reset --publish # Reset and make accessible from LAN
```
## PostgreSQL
The script will output:
```bash
export DATABASE_URL='postgresql://postgres@127.0.0.1:5432/postgres'
```
Add that line to your shell or `.env` file to connect.
## Redis
When using the `--redis` flag, the script will output:
```bash
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:
## 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:**
```bash
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:
```bash
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:
```bash
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.
---