env and yml

This commit is contained in:
2025-05-20 11:34:12 +07:00
parent cd880e3854
commit a07d3affb0
3 changed files with 17 additions and 4 deletions

View File

@@ -25,5 +25,5 @@ WORKDIR /root/
COPY --from=builder /app/main .
COPY --from=builder /app/.env .
EXPOSE 8086
EXPOSE 8080
CMD ["./main"]

View File

@@ -17,12 +17,12 @@ services:
# DATABASE SIMRS V3.0
- SIMRS_STAG_HOST=10.10.123.223
- SIMRS_STAG_PORT=5432
- SIMRS_STAG_NAME=simrsbackup
- SIMRS_STAG_NAME=simrs-stag
- SIMRS_STAG_USER=simtest
- SIMRS_STAG_PASS=12345
# DATABASE SATU DATA
- SATUDATA_HOST=10.10.123.165
- SATUDATA_USER=stim
- SATUDATA_PASS=stim*RS54
- SATUDATA_USERNAME=stim
- SATUDATA_PASSWORD=stim*RS54
- SATUDATA_NAME=satu_db
- SATUDATA_PORT=5000

View File

@@ -27,6 +27,11 @@ type service struct {
}
var (
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")
hostSatudata = os.Getenv("SATUDATA_HOST")
userNameSatudata = os.Getenv("SATUDATA_USER")
passwordSatudata = os.Getenv("SATUDATA_PASS")
@@ -40,7 +45,14 @@ func New() Service {
if dbInstance != nil {
return dbInstance
}
simrs := fmt.Sprintf("host=%s user=%s password=%s dbname=%s port=%s sslmode=disable TimeZone=Asia/Jakarta", hostSimrs, userNameSimrs, passwordSimrs, dbNameSimrs, portSimrs)
SimrsDB, err := gorm.Open(postgres.Open(simrs), &gorm.Config{})
if err != nil {
log.Fatal("Failed to connect to SIM database: ", err)
} else {
log.Println("Successfully connected to the database")
}
satudata := fmt.Sprintf("host=%s user=%s password=%s dbname=%s port=%s sslmode=disable TimeZone=Asia/Jakarta", hostSatudata, userNameSatudata, passwordSatudata, dbNameSatudata, portSatudata)
SatudataDB, err := gorm.Open(postgres.Open(satudata), &gorm.Config{})
@@ -50,6 +62,7 @@ func New() Service {
log.Println("Successfully connected to the database")
}
dbInstance = &service{
simrsDB: SimrsDB,
satuDataDB: SatudataDB,
}
return dbInstance