From d199595ee143f8d419f326cad0d686fb0997a025 Mon Sep 17 00:00:00 2001 From: mirza Date: Mon, 3 Feb 2025 07:50:50 +0700 Subject: [PATCH] fix env --- docker-compose.yml | 10 +++++----- docker-push.sh | 27 +++++++++++++++++++++++++++ internal/database/database.go | 10 +++++----- 3 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 docker-push.sh diff --git a/docker-compose.yml b/docker-compose.yml index 9aaed72..df6b6c4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,11 +15,11 @@ services: # TIMEZONE - TZ=Asia/Jakarta # DATABASE SIMRS V3.0 - - POSTGRE_DB_HOST=10.10.123.223 - - POSTGRE_DB_PORT=5432 - - POSTGRE_DB_NAME=simrsbackup - - POSTGRE_DB_USER=simtest - - POSTGRE_DB_PASS=12345 + - SIMRS_STAG_HOST=10.10.123.223 + - SIMRS_STAG_PORT=5432 + - SIMRS_STAG_NAME=simrsbackup + - SIMRS_STAG_USER=simtest + - SIMRS_STAG_PASS=12345 # DATABASE SATU DATA - SATUDATA_HOST=10.10.123.165 - SATUDATA_USERNAME=stim diff --git a/docker-push.sh b/docker-push.sh new file mode 100644 index 0000000..0510d0d --- /dev/null +++ b/docker-push.sh @@ -0,0 +1,27 @@ +!/bin/bash + +#get image name +remote_url=$(git remote get-url origin) +image=$(echo $remote_url | sed 's|https://||g; s|.git||g') + +#get branch name +branch_name=$(git rev-parse --abbrev-ref HEAD) +clean_branch_name=${branch_name##*/} + +#get timestamp for the tag +timestamp=$(date +%Y%m%d%H%M%S) + +tag=$image:$timestamp-$clean_branch_name +latest=$image:latest-$clean_branch_name + +#build image +docker build -t $tag . +docker tag $tag $latest + +#push to dockerhub +docker login git.rssa.top -u stim -p 4fde63b07906e7bfa6b3493d76d153a3981039b9 +docker push $tag +docker push $latest + +#remove dangling images +docker system prune -f diff --git a/internal/database/database.go b/internal/database/database.go index 2e6c74c..784974c 100644 --- a/internal/database/database.go +++ b/internal/database/database.go @@ -25,11 +25,11 @@ type service struct { } var ( - hostSimrs = os.Getenv("POSTGRE_DB_HOST") - userNameSimrs = os.Getenv("POSTGRE_DB_USER") - passwordSimrs = os.Getenv("POSTGRE_DB_PASS") - dbNameSimrs = os.Getenv("POSTGRE_DB_NAME") - portSimrs = os.Getenv("POSTGRE_DB_PORT") + hostSimrs = os.Getenv("SIMRS_STAG_HOST") + userNameSimrs = os.Getenv("SIMRS_STAG_USER") + passwordSimrs = os.Getenv("SIMRS_STAG_PASS") + dbNameSimrs = os.Getenv("SIMRS_STAG_NAME") + portSimrs = os.Getenv("SIMRS_STAG_PORT") dbInstance *service )