diff --git a/Dockerfile b/Dockerfile index 032a8e5..2d8c737 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,8 @@ WORKDIR /app COPY . . +RUN apk add --no-cache tzdata + RUN go mod download RUN go build -o /goapp @@ -12,6 +14,7 @@ FROM alpine:3.19 AS build-release-stage WORKDIR / +COPY --from=build-stage /usr/share/zoneinfo /usr/share/zoneinfo COPY --from=build-stage /goapp /goapp COPY --from=build-stage /app/templates ./templates diff --git a/drivers/mysql/mysql.go b/drivers/mysql/mysql.go index ce992d7..af73423 100644 --- a/drivers/mysql/mysql.go +++ b/drivers/mysql/mysql.go @@ -5,6 +5,7 @@ import ( "e-complaint-api/drivers/mysql/seeder" "e-complaint-api/entities" "fmt" + "time" "gorm.io/driver/mysql" "gorm.io/gorm" @@ -19,12 +20,19 @@ type Config struct { } func ConnectDB(config Config) *gorm.DB { - dsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=True&loc=Local", + loc, err := time.LoadLocation("Asia/Jakarta") + if err != nil { + panic(err) + } + + // Creating the DSN with loc parameter + dsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=True&loc=%s", config.DB_USERNAME, config.DB_PASSWORD, config.DB_HOST, config.DB_PORT, config.DB_NAME, + loc.String(), ) db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{}) if err != nil {