Updated Setup script workflows

This commit is contained in:
Jyotirmoy Bandyopadhayaya 2023-01-14 11:59:53 +05:30
parent 840ddb6749
commit 2cff7b90a3
Signed by: bravo68web
GPG Key ID: F5671FD7BCB9917A
7 changed files with 30 additions and 9 deletions

View File

@ -1 +1,5 @@
echo "Hello from API"
#!/bin/bash
source "packages/config-store/.env"
echo "Fetching API Key with env file from Config Store"
wget --user $BASIC_USERNAME --password $BASIC_PASSWORD http://127.0.0.1:$CS_PORT/private/api.env -O packages/api/.env

View File

@ -0,0 +1,3 @@
USERNAME=admin
PASSWORD=pass
PORT=0000

6
packages/config-store/.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
Dockerfile
.env
public/*
private/*
!public/.gitkeep
!private/.gitkeep

View File

@ -8,5 +8,6 @@ RUN go get
RUN go build
CMD ["config-store"]
EXPOSE 0000
CMD ["/app/config-store"]

View File

@ -70,7 +70,7 @@ func main() {
app.Static("/private", "private")
port := goDotEnvVariable("PORT")
port := goDotEnvVariable("CS_PORT")
if port == "" {
port = "3000"
}

View File

@ -14,5 +14,7 @@ echo "BASIC_USERNAME=$username" >> $ENV_PATH
echo "BASIC_PASSWORD=$password" >> $ENV_PATH
echo "PORT=$port" >> $ENV_PATH
sed "s/0000/$port/g" packages/config-store/Dockerfile.example > packages/config-store/Dockerfile
# Echo a message to confirm the file has been saved
echo "Configuration saved to packages/config-store/.env"

View File

@ -12,21 +12,28 @@ echo ""
echo "This script will setup .env all the packages in the $PACKAGES_FOLDER folder."
echo ""
# Ask If setting up for the first time, then only setup "config-store" package
read -p "Is this the first time you are setting up the project? [y/N] " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "${bold} Setting up config-store ${normal}"
bash packages/config-store/setup.sh
echo ""
exit 0
fi
# Iterate through all packages
for package in $PACKAGES_FOLDER/*; do
# Check if package is a directory
echo "${bold} Setting up $package ${normal}"
echo "${bold} Setting up $package ${normal}"
if [ -d "$package" ]; then
# Check if .setup file is present. If not, skip package
if [ ! -f "$package/.setup" ]; then
echo "Skipping $package"
echo ""
continue
fi
# Check if .env file presen. If present, ask user if he wants to overwrite it
if [ -f "$package/.env" ]; then
read -p "Overwrite $package/.env? [y/N] " -n 1 -r
@ -36,10 +43,8 @@ for package in $PACKAGES_FOLDER/*; do
continue
fi
fi
chmod +x "$package/setup.sh"
bash "$package/setup.sh"
echo ""
fi
done