Compare commits

..

No commits in common. "dd013322fe704c738f4a31a1ae6c51d0f46d6015" and "ba7929fd9f697a553f06dc81783316c781b2ef6e" have entirely different histories.

4 changed files with 26 additions and 42 deletions

View File

@ -7,7 +7,7 @@ build-2:
image: docker:24 image: docker:24
services: services:
- name: docker:24-dind - name: docker:24-dind
command: ["--insecure-registry=38.47.185.86:8900"] command: ["--insecure-registry=103.31.38.120:8900"]
variables: variables:
DOCKER_HOST: tcp://docker:2375 DOCKER_HOST: tcp://docker:2375
@ -15,10 +15,10 @@ build-2:
script: script:
- docker version - docker version
- docker login -u $DEPLOY_USERNAME -p $DEPLOY_TOKEN 38.47.185.86:8900 - docker login -u $DEPLOY_USERNAME -p $DEPLOY_TOKEN 103.31.38.120:8900
- docker build -t registry.gitlab.com/hanifsalafi/web-medols-be:dev . - docker build -t registry.gitlab.com/hanifsalafi/web-medols-be:dev .
- docker tag registry.gitlab.com/hanifsalafi/web-medols-be:dev 38.47.185.86:8900/medols/web-medols-be:dev - docker tag registry.gitlab.com/hanifsalafi/web-medols-be:dev 103.31.38.120:8900/medols/web-medols-be:dev
- docker push 38.47.185.86:8900/medols/web-medols-be:dev - docker push 103.31.38.120:8900/medols/web-medols-be:dev
deploy: deploy:
stage: deploy stage: deploy

View File

@ -59,7 +59,7 @@ func (m *Middleware) Register(db *database.Database) {
m.App.Use(cors.New(cors.Config{ m.App.Use(cors.New(cors.Config{
Next: utilsSvc.IsEnabled(m.Cfg.Middleware.Cors.Enable), Next: utilsSvc.IsEnabled(m.Cfg.Middleware.Cors.Enable),
AllowOrigins: "http://localhost:3000, http://localhost:4000, https://dev.mikulnews.com, https://n8n.qudoco.com, https://narasiahli.com, https://dev.asuransiaman.com, https://dev.beritabumn.com, https://dev.kabarharapan.com, https://dev.kebaikanindonesia.com, https://dev.isukini.com, https://dev.bhayangkarakita.com, https://dev.infokreasi.com, https://dev.milenialbersuara.com, https://dev2.fokusaja.com, https://dev.arahnegeri.com, https://dev.wargabicara.com", AllowOrigins: "http://localhost:3000, http://localhost:4000, https://dev.mikulnews.com, https://n8n.qudoco.com, https://narasiahli.com, https://dev.asuransiaman.com, https://dev.beritabumn.com, https://dev.kabarharapan.com, https://dev.kebaikanindonesia.com, https://dev.isukini.com, https://dev.bhayangkarakita.com, https://dev.infokreasi.com, https://dev.milenialbersuara.com, https://dev2.fokusaja.com, https://dev.arahnegeri.com, https://dev.wargabicara.com",
AllowMethods: "HEAD, GET, POST, PUT, DELETE, OPTIONS, PATCH", AllowMethods: "HEAD, GET, POST, PUT, DELETE, OPTION, PATCH",
AllowHeaders: "Origin, Content-Type, Accept, Accept-Language, Authorization, X-Requested-With, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Allow-Origin, Access-Control-Allow-Credentials, X-Csrf-Token, Cookie, Set-Cookie, X-Client-Key", AllowHeaders: "Origin, Content-Type, Accept, Accept-Language, Authorization, X-Requested-With, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Allow-Origin, Access-Control-Allow-Credentials, X-Csrf-Token, Cookie, Set-Cookie, X-Client-Key",
ExposeHeaders: "Content-Length, Content-Type", ExposeHeaders: "Content-Length, Content-Type",
AllowCredentials: true, AllowCredentials: true,

View File

@ -2,10 +2,9 @@ package config
import ( import (
"context" "context"
"log"
"github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials" "github.com/minio/minio-go/v7/pkg/credentials"
"log"
) )
// MinioSetup struct // MinioSetup struct
@ -31,41 +30,26 @@ func (_minio *MinioStorage) ConnectMinio() (*minio.Client, error) {
bucketName := _minio.Cfg.ObjectStorage.MinioStorage.BucketName bucketName := _minio.Cfg.ObjectStorage.MinioStorage.BucketName
location := _minio.Cfg.ObjectStorage.MinioStorage.Location location := _minio.Cfg.ObjectStorage.MinioStorage.Location
// Log connection attempt
log.Printf("[MinIO] Attempting to connect to MinIO at endpoint: %s (SSL: %v)", endpoint, useSSL)
// Initialize minio client object. // Initialize minio client object.
minioClient, errInit := minio.New(endpoint, &minio.Options{ minioClient, errInit := minio.New(endpoint, &minio.Options{
Creds: credentials.NewStaticV4(accessKeyID, secretAccessKey, ""), Creds: credentials.NewStaticV4(accessKeyID, secretAccessKey, ""),
Secure: useSSL, Secure: useSSL,
}) })
if errInit != nil { if errInit != nil {
log.Printf("[MinIO] ERROR: Failed to initialize MinIO client. Endpoint: %s, SSL: %v, Error: %v", endpoint, useSSL, errInit) log.Fatalln(errInit)
return nil, errInit
} }
log.Printf("[MinIO] MinIO client initialized successfully. Checking bucket: %s", bucketName) err := minioClient.MakeBucket(ctx, bucketName, minio.MakeBucketOptions{Region: location})
if err != nil {
// Check if bucket exists first // Check to see if we already own this bucket (which happens if you run this twice)
exists, errBucketExists := minioClient.BucketExists(ctx, bucketName) exists, errBucketExists := minioClient.BucketExists(ctx, bucketName)
if errBucketExists != nil { if errBucketExists == nil && exists {
log.Printf("[MinIO] ERROR: Failed to check if bucket exists. Bucket: %s, Error: %v", bucketName, errBucketExists) log.Printf("We already own %s\n", bucketName)
return nil, errBucketExists } else {
} log.Fatalln(err)
if exists {
log.Printf("[MinIO] Bucket '%s' already exists and is accessible", bucketName)
} else {
// Try to create the bucket
log.Printf("[MinIO] Bucket '%s' does not exist. Attempting to create it in location: %s", bucketName, location)
err := minioClient.MakeBucket(ctx, bucketName, minio.MakeBucketOptions{Region: location})
if err != nil {
log.Printf("[MinIO] ERROR: Failed to create bucket. Bucket: %s, Location: %s, Error: %v", bucketName, location, err)
return nil, err
} }
log.Printf("[MinIO] Successfully created bucket '%s' in location '%s'", bucketName, location) } else {
log.Printf("Successfully created %s\n", bucketName)
} }
return minioClient, errInit
log.Printf("[MinIO] Successfully connected to MinIO and bucket '%s' is ready", bucketName)
return minioClient, nil
} }

View File

@ -1,18 +1,18 @@
# Configuration vars for cmd/app # Configuration vars for cmd/app
[app] [app]
name = "Fiber starter" name = "Fiber starter"
host = "http://38.47.185.86" host = "http://103.31.38.120"
port = ":8800" port = ":8800"
domain = "https://dev.mikulnews.com/api" domain = "https://dev.mikulnews.com/api"
external-port = ":8804" external-port = ":8802"
idle-timeout = 5 # As seconds idle-timeout = 5 # As seconds
print-routes = false print-routes = false
prefork = false prefork = true
production = false production = false
body-limit = 1048576000 # "100 * 1024 * 1024" body-limit = 1048576000 # "100 * 1024 * 1024"
[db.postgres] [db.postgres]
dsn = "postgresql://medols_user:MedolsDB@2025@38.47.185.79:5432/medols_db" # <driver>://<username>:<password>@<host>:<port>/<database> dsn = "postgresql://medols_user:MedolsDB@2025@157.10.161.198:5432/medols_db" # <driver>://<username>:<password>@<host>:<port>/<database>
log-mode = "ERROR" log-mode = "ERROR"
migrate = true migrate = true
seed = false seed = false
@ -27,7 +27,7 @@ prettier = true
endpoint = "is3.cloudhost.id" endpoint = "is3.cloudhost.id"
access-key-id = "YRP1RM617986USRU6NN8" access-key-id = "YRP1RM617986USRU6NN8"
secret-access-key = "vfbwQDYb1m7nfzo4LVEz90BIyOWfBMZ6bfGQbqDO" secret-access-key = "vfbwQDYb1m7nfzo4LVEz90BIyOWfBMZ6bfGQbqDO"
use-ssl = true use-ssl = false
bucket-name = "mikulnews" bucket-name = "mikulnews"
location = "us-east-1" location = "us-east-1"
@ -49,8 +49,8 @@ enable = true
enable = true enable = true
[middleware.limiter] [middleware.limiter]
enable = false enable = true
max = 500 max = 20
expiration_seconds = 60 expiration_seconds = 60
[middleware.csrf] [middleware.csrf]
@ -66,7 +66,7 @@ enable = true
retention = 30 retention = 30
[keycloak] [keycloak]
endpoint = "http://38.47.185.86:8008" endpoint = "http://103.31.38.120:8008"
realm = "medols" realm = "medols"
client-id = "medols-app" client-id = "medols-app"
client-secret = "iyonEpZbAUs20quwaNFLMwRX7MUgPRlS" client-secret = "iyonEpZbAUs20quwaNFLMwRX7MUgPRlS"