-
-
Save mustafaturan/289eb1b87844bb467ffa5ba0264d72e0 to your computer and use it in GitHub Desktop.
Set monoflake node id from ip address (digitalocean)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
APP_ENV=production | |
MONOFLAKE_NODE=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
up: | |
MONOFLAKE_NODE=$(shell ip -4 addr show eth1 | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | head -n 1 | cut -d. -f4); \ | |
echo "Monoflake node id: $$MONOFLAKE_NODE"; \ | |
sed -i.bak "s/^MONOFLAKE_NODE=.*/MONOFLAKE_NODE=$$MONOFLAKE_NODE/" .env && \ | |
echo "Updated MONOFLAKE_NODE to $$MONOFLAKE_NODE"; \ | |
docker build . -t <app name>; \ | |
docker compose down; \ | |
docker compose --env-file=${PWD}/.env up -d; \ | |
sleep 3; \ | |
MONOFLAKE_NODE=0; \ | |
sed -i.bak "s/^MONOFLAKE_NODE=.*/MONOFLAKE_NODE=$$MONOFLAKE_NODE/" .env && \ | |
echo "Updated MONOFLAKE_NODE to $$MONOFLAKE_NODE"; | |
down: | |
docker compose down |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment