17 Commits
Author SHA1 Message Date
Ardeman 211f0154be fix: update default environment mode to local and adjust database configurations 2025-04-24 11:25:36 +08:00
Ardeman 136c4634c8 fix: enable SSL for Redis configuration in debug environment 2025-04-23 19:10:31 +08:00
Ardeman 987ac2fe4a fix: update Redis configuration to use SSL and adjust related settings 2025-04-23 19:09:24 +08:00
Ardeman 02d8a509ff fix: update Redis credentials in staging configuration 2025-04-23 18:45:49 +08:00
Ardeman e29bd7986f fix: update default environment mode to staging and add local configuration file 2025-04-23 18:18:44 +08:00
Ardeman 4bf318a9c2 fix: update PostgreSQL configuration for staging environment 2025-04-23 18:01:55 +08:00
Ardeman 52085a5be0 feat: add staging configuration file with server, database, and OSS settings 2025-04-23 17:52:58 +08:00
Ardeman 21c4c1efba fix: update MinIO endpoint and URLs to use news-cdn.legalgo.id in debug.yaml and production.yaml 2025-04-23 14:50:59 +08:00
Ardeman c17540cc20 fix: update MinIO endpoint and URLs to use crm-cdn.legalgo.id in production.yaml 2025-04-23 14:27:26 +08:00
Ardeman 714b1ff4eb fix: correct public URL formatting in GetPublicURL function 2025-04-23 13:50:41 +08:00
Ardeman abc3ce8d2b fix: update bucket name to 'uploads' in debug.yaml and production.yaml 2025-04-23 13:48:28 +08:00
Ardeman cd1097d3d0 fix: update MinIO endpoint to include the full domain in debug.yaml and production.yaml 2025-04-23 13:39:43 +08:00
Ardeman 52991059c6 fix: update bucket name to legalgonews-production in debug.yaml and production.yaml 2025-04-23 13:17:32 +08:00
Ardeman a7ef3f8ca2 fix: update SSL mode configuration in debug.yaml and NewDB function 2025-04-23 13:11:57 +08:00
Ardeman 6f1ac37915 fix: update redis host configuration in production.yaml 2025-04-23 12:57:06 +08:00
Ardeman e20c63e694 feat: add debug configuration file for server, jwt, postgresql, oss, and redis 2025-04-23 12:50:28 +08:00
Ardeman abcbc014a2 feat: add production configuration files for server, jwt, postgresql, oss, and redis 2025-04-23 12:39:50 +08:00
13 changed files with 130 additions and 94 deletions
-35
View File
@@ -1,35 +0,0 @@
name: Deploy to AWS Lambda via SAM
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24' # adjust to your Go version
- name: Set up AWS SAM CLI
uses: aws-actions/setup-sam@v2
- name: Build with SAM
run: sam build
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Deploy with SAM
run: |
sam deploy --no-confirm-changeset --no-fail-on-empty-changeset --stack-name legalgo-stack --capabilities CAPABILITY_IAM --region ${{ secrets.AWS_REGION }} --resolve-s3
-2
View File
@@ -1,2 +0,0 @@
build:
GOOS=linux GOARCH=amd64 go build -o main main.go
+5 -4
View File
@@ -12,14 +12,15 @@ import (
const (
YAML_PATH = "env/%s"
ENV_MODE = "ENV_MODE"
DEFAULT_ENV_MODE = "development"
DEFAULT_ENV_MODE = "local"
)
var (
validEnvMode = map[string]struct{}{
"local": {},
"development": {},
"production": {},
"local": {},
"staging": {},
"production": {},
"debug": {},
}
)
+1 -1
View File
@@ -6,7 +6,7 @@ type Redis struct {
DB int `mapstructure:"db"`
Username string `mapstructure:"username"`
Password string `mapstructure:"password"`
SslMode string `mapstructure:"ssl-mode"`
SSL bool `mapstructure:"ssl"`
Debug bool `mapstructure:"debug"`
MaxIdleConnectionsInSecond int `mapstructure:"max-idle-connections-in-second"`
MaxOpenConnectionsInSecond int `mapstructure:"max-open-connections-in-second"`
+2 -1
View File
@@ -15,12 +15,13 @@ type DB struct {
func NewDB(cfg *config.Config) (*DB, error) {
dsn := fmt.Sprintf(
"host=%s user=%s password=%s dbname=%s port=%v sslmode=disable",
"host=%s user=%s password=%s dbname=%s port=%v sslmode=%s",
cfg.Database.Host,
cfg.Database.Username,
cfg.Database.Password,
cfg.Database.DB,
cfg.Database.Port,
cfg.Database.SslMode,
)
if dsn == "" {
-3
View File
@@ -1,3 +0,0 @@
#!/bin/bash
sam build
sam deploy --guided
+43
View File
@@ -0,0 +1,43 @@
server:
base-url: https://api.legalgo.id/core
local-url: http://localhost:3300
port: 3300
jwt:
token:
expires-ttl: 1440
secret: "5Lm25V3Qd7aut8dr4QUxm5PZUrSFs"
postgresql:
host: dpg-d046h549c44c739arfv0-a.singapore-postgres.render.com
port: 5432
driver: postgres
db: legalgonews_prod
username: legalgo_admin
password: "656ogwc0JlLEVQyHnT5RrrYa7762iBQQ"
ssl-mode: require
max-idle-connections-in-second: 600
max-open-connections-in-second: 600
connection-max-life-time-in-second: 600
debug: false
oss:
access_key_id: GTK7i3SVy9llQeGH0Htv
access_key_secret: 2psmKXZFpevA9n5ntSDRMqFBpZuSz32dvtXjYclf
endpoint: news-cdn.legalgo.id
bucket_name: uploads
log_level: Error
host_url: https://news-cdn.legalgo.id
public_url: https://news-cdn.legalgo.id
redis:
host: singapore-keyvalue.render.com
port: 6379
username: red-d046l42dbo4c73ea9iag
password: 7cZvu08JKuO9MPNxBb97tZCVNj0ZGNp2
db: 5
ssl: true
max-idle-connections-in-second: 600
max-open-connections-in-second: 600
connection-max-life-time-in-second: 600
debug: false
+43
View File
@@ -0,0 +1,43 @@
server:
base-url: https://api.legalgo.id/core
local-url: http://localhost:3300
port: 3300
jwt:
token:
expires-ttl: 1440
secret: "5Lm25V3Qd7aut8dr4QUxm5PZUrSFs"
postgresql:
host: dpg-d04bi9juibrs73augcc0-a.singapore-postgres.render.com
port: 5432
driver: postgres
db: legalgonews_dev
username: legalgo_admin
password: "5h7DCBR1T8pug6AlbrHXqIDAr9o2vnky"
ssl-mode: require
max-idle-connections-in-second: 600
max-open-connections-in-second: 600
connection-max-life-time-in-second: 600
debug: false
oss:
access_key_id: GTK7i3SVy9llQeGH0Htv
access_key_secret: 2psmKXZFpevA9n5ntSDRMqFBpZuSz32dvtXjYclf
endpoint: news-cdn.legalgo.id
bucket_name: uploads-staging
log_level: Error
host_url: https://news-cdn.legalgo.id
public_url: https://news-cdn.legalgo.id
redis:
host: singapore-keyvalue.render.com
port: 6379
username: red-d04c8k49c44c739ga8dg
password: ItPzniHv94yr8vY4HTrhCfKoibqBh61T
db: 5
ssl: true
max-idle-connections-in-second: 600
max-open-connections-in-second: 600
connection-max-life-time-in-second: 600
debug: false
+11 -10
View File
@@ -9,12 +9,12 @@ jwt:
secret: "5Lm25V3Qd7aut8dr4QUxm5PZUrSFs"
postgresql:
host: legalgodb.ctuok62cmn6i.ap-southeast-1.rds.amazonaws.com
host: dpg-d046h549c44c739arfv0-a
port: 5432
driver: postgres
db: legalgonews
db: legalgonews_prod
username: legalgo_admin
password: "K4K!2Kg7cKW6H&4A2aBy2dFCRY3Sh"
password: "656ogwc0JlLEVQyHnT5RrrYa7762iBQQ"
ssl-mode: disable
max-idle-connections-in-second: 600
max-open-connections-in-second: 600
@@ -22,17 +22,18 @@ postgresql:
debug: false
oss:
access_key_id: cf9a475e18bc7626cbdbf09709d82a64
access_key_secret: 91f3321294d3e23035427a0ecb893ada
endpoint: sin1.contabostorage.com
bucket_name: legalgonews-dev
access_key_id: GTK7i3SVy9llQeGH0Htv
access_key_secret: 2psmKXZFpevA9n5ntSDRMqFBpZuSz32dvtXjYclf
endpoint: news-cdn.legalgo.id
bucket_name: uploads
log_level: Error
host_url: https://sin1.contabostorage.com
public_url: https://sin1.contabostorage.com/fda98c2228f246f29a7e466b86b3b9e7
host_url: https://news-cdn.legalgo.id
public_url: https://news-cdn.legalgo.id
redis:
host: legalgocache-qn8fuh.serverless.apse1.cache.amazonaws.com
host: red-d046l42dbo4c73ea9iag
port: 6379
password: 7cZvu08JKuO9MPNxBb97tZCVNj0ZGNp2
db: 5
ssl: false
max-idle-connections-in-second: 600
+13 -13
View File
@@ -9,12 +9,12 @@ jwt:
secret: "5Lm25V3Qd7aut8dr4QUxm5PZUrSFs"
postgresql:
host: 62.72.45.250
port: 20826
host: dpg-d04bi9juibrs73augcc0-a
port: 5432
driver: postgres
db: legalgonews-dev
db: legalgonews_dev
username: legalgo_admin
password: "K4K!2Kg7c@KW6H&4A2aBy2dFCRY3Sh"
password: "5h7DCBR1T8pug6AlbrHXqIDAr9o2vnky"
ssl-mode: disable
max-idle-connections-in-second: 600
max-open-connections-in-second: 600
@@ -22,18 +22,18 @@ postgresql:
debug: false
oss:
access_key_id: cf9a475e18bc7626cbdbf09709d82a64
access_key_secret: 91f3321294d3e23035427a0ecb893ada
endpoint: sin1.contabostorage.com
bucket_name: legalgonews-dev
access_key_id: GTK7i3SVy9llQeGH0Htv
access_key_secret: 2psmKXZFpevA9n5ntSDRMqFBpZuSz32dvtXjYclf
endpoint: news-cdn.legalgo.id
bucket_name: uploads-staging
log_level: Error
host_url: https://sin1.contabostorage.com
public_url: https://sin1.contabostorage.com/fda98c2228f246f29a7e466b86b3b9e7
host_url: https://news-cdn.legalgo.id
public_url: https://news-cdn.legalgo.id
redis:
host: 62.72.45.250
port: 26379
password: mDtpsyEW8W26vwLhglpO
host: red-d04c8k49c44c739ga8dg
port: 6379
password: ItPzniHv94yr8vY4HTrhCfKoibqBh61T
db: 5
ssl: false
max-idle-connections-in-second: 600
+1 -1
View File
@@ -66,7 +66,7 @@ func (r *OssRepositoryImpl) GetPublicURL(fileName string) string {
if fileName == "" {
return ""
}
return fmt.Sprintf("%s:%s%s", r.cfg.GetPublicURL(), r.cfg.GetBucketName(), fileName)
return fmt.Sprintf("%s/%s%s", r.cfg.GetPublicURL(), r.cfg.GetBucketName(), fileName)
}
func (r *OssRepositoryImpl) DeleteObject(ctx context.Context, fileName string) error {
+11 -2
View File
@@ -1,6 +1,7 @@
package redisaccessor
import (
"crypto/tls"
"fmt"
"legalgo-BE-go/config"
@@ -16,11 +17,19 @@ func Get() *redis.Client {
func New(cfg *config.Config) *redis.Client {
addr := fmt.Sprintf("%s:%s", cfg.Redis.Host, cfg.Redis.Port)
redisClient = redis.NewClient(&redis.Options{
options := &redis.Options{
Addr: addr,
Password: cfg.Redis.Password,
DB: cfg.Redis.DB,
})
}
if cfg.Redis.Username != "" {
options.Username = cfg.Redis.Username
}
if cfg.Redis.SSL {
options.TLSConfig = &tls.Config{}
}
redisClient = redis.NewClient(options)
return redisClient
}
-22
View File
@@ -1,22 +0,0 @@
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Go Lambda API deployed with AWS SAM
Globals:
Function:
Timeout: 10
Resources:
ApiFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: legalgo-api
Handler: main
Runtime: provided.al2023
CodeUri: cmd/legalgo
Events:
Api:
Type: Api
Properties:
Path: /
Method: ANY