Compare commits
9
Commits
dev
..
ec6ba877d7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec6ba877d7 | ||
|
|
131113f75b | ||
|
|
356351516c | ||
|
|
0bf6d57eb2 | ||
|
|
b7e988cfff | ||
|
|
cbfa618ab6 | ||
|
|
2e5c8dcde4 | ||
|
|
52916998f0 | ||
|
|
ecc6c3b866 |
@@ -0,0 +1,36 @@
|
|||||||
|
name: Deploy to AWS Lambda via SAM
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
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
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
build:
|
||||||
|
GOOS=linux GOARCH=amd64 go build -o main main.go
|
||||||
|
|
||||||
|
build-ApiFunction: build
|
||||||
+2
-3
@@ -12,15 +12,14 @@ import (
|
|||||||
const (
|
const (
|
||||||
YAML_PATH = "env/%s"
|
YAML_PATH = "env/%s"
|
||||||
ENV_MODE = "ENV_MODE"
|
ENV_MODE = "ENV_MODE"
|
||||||
DEFAULT_ENV_MODE = "local"
|
DEFAULT_ENV_MODE = "development"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
validEnvMode = map[string]struct{}{
|
validEnvMode = map[string]struct{}{
|
||||||
"local": {},
|
"local": {},
|
||||||
"staging": {},
|
"development": {},
|
||||||
"production": {},
|
"production": {},
|
||||||
"debug": {},
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ type Redis struct {
|
|||||||
DB int `mapstructure:"db"`
|
DB int `mapstructure:"db"`
|
||||||
Username string `mapstructure:"username"`
|
Username string `mapstructure:"username"`
|
||||||
Password string `mapstructure:"password"`
|
Password string `mapstructure:"password"`
|
||||||
SSL bool `mapstructure:"ssl"`
|
SslMode string `mapstructure:"ssl-mode"`
|
||||||
Debug bool `mapstructure:"debug"`
|
Debug bool `mapstructure:"debug"`
|
||||||
MaxIdleConnectionsInSecond int `mapstructure:"max-idle-connections-in-second"`
|
MaxIdleConnectionsInSecond int `mapstructure:"max-idle-connections-in-second"`
|
||||||
MaxOpenConnectionsInSecond int `mapstructure:"max-open-connections-in-second"`
|
MaxOpenConnectionsInSecond int `mapstructure:"max-open-connections-in-second"`
|
||||||
|
|||||||
+1
-2
@@ -15,13 +15,12 @@ type DB struct {
|
|||||||
|
|
||||||
func NewDB(cfg *config.Config) (*DB, error) {
|
func NewDB(cfg *config.Config) (*DB, error) {
|
||||||
dsn := fmt.Sprintf(
|
dsn := fmt.Sprintf(
|
||||||
"host=%s user=%s password=%s dbname=%s port=%v sslmode=%s",
|
"host=%s user=%s password=%s dbname=%s port=%v sslmode=disable",
|
||||||
cfg.Database.Host,
|
cfg.Database.Host,
|
||||||
cfg.Database.Username,
|
cfg.Database.Username,
|
||||||
cfg.Database.Password,
|
cfg.Database.Password,
|
||||||
cfg.Database.DB,
|
cfg.Database.DB,
|
||||||
cfg.Database.Port,
|
cfg.Database.Port,
|
||||||
cfg.Database.SslMode,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if dsn == "" {
|
if dsn == "" {
|
||||||
|
|||||||
Vendored
-43
@@ -1,43 +0,0 @@
|
|||||||
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
|
|
||||||
+13
-13
@@ -9,12 +9,12 @@ jwt:
|
|||||||
secret: "5Lm25V3Qd7aut8dr4QUxm5PZUrSFs"
|
secret: "5Lm25V3Qd7aut8dr4QUxm5PZUrSFs"
|
||||||
|
|
||||||
postgresql:
|
postgresql:
|
||||||
host: dpg-d04bi9juibrs73augcc0-a
|
host: 62.72.45.250
|
||||||
port: 5432
|
port: 20826
|
||||||
driver: postgres
|
driver: postgres
|
||||||
db: legalgonews_dev
|
db: legalgonews-dev
|
||||||
username: legalgo_admin
|
username: legalgo_admin
|
||||||
password: "5h7DCBR1T8pug6AlbrHXqIDAr9o2vnky"
|
password: "K4K!2Kg7c@KW6H&4A2aBy2dFCRY3Sh"
|
||||||
ssl-mode: disable
|
ssl-mode: disable
|
||||||
max-idle-connections-in-second: 600
|
max-idle-connections-in-second: 600
|
||||||
max-open-connections-in-second: 600
|
max-open-connections-in-second: 600
|
||||||
@@ -22,18 +22,18 @@ postgresql:
|
|||||||
debug: false
|
debug: false
|
||||||
|
|
||||||
oss:
|
oss:
|
||||||
access_key_id: GTK7i3SVy9llQeGH0Htv
|
access_key_id: cf9a475e18bc7626cbdbf09709d82a64
|
||||||
access_key_secret: 2psmKXZFpevA9n5ntSDRMqFBpZuSz32dvtXjYclf
|
access_key_secret: 91f3321294d3e23035427a0ecb893ada
|
||||||
endpoint: news-cdn.legalgo.id
|
endpoint: sin1.contabostorage.com
|
||||||
bucket_name: uploads-staging
|
bucket_name: legalgonews-dev
|
||||||
log_level: Error
|
log_level: Error
|
||||||
host_url: https://news-cdn.legalgo.id
|
host_url: https://sin1.contabostorage.com
|
||||||
public_url: https://news-cdn.legalgo.id
|
public_url: https://sin1.contabostorage.com/fda98c2228f246f29a7e466b86b3b9e7
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
host: red-d04c8k49c44c739ga8dg
|
host: 62.72.45.250
|
||||||
port: 6379
|
port: 26379
|
||||||
password: ItPzniHv94yr8vY4HTrhCfKoibqBh61T
|
password: mDtpsyEW8W26vwLhglpO
|
||||||
db: 5
|
db: 5
|
||||||
ssl: false
|
ssl: false
|
||||||
max-idle-connections-in-second: 600
|
max-idle-connections-in-second: 600
|
||||||
Vendored
-43
@@ -1,43 +0,0 @@
|
|||||||
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
|
|
||||||
Vendored
+10
-11
@@ -9,12 +9,12 @@ jwt:
|
|||||||
secret: "5Lm25V3Qd7aut8dr4QUxm5PZUrSFs"
|
secret: "5Lm25V3Qd7aut8dr4QUxm5PZUrSFs"
|
||||||
|
|
||||||
postgresql:
|
postgresql:
|
||||||
host: dpg-d046h549c44c739arfv0-a
|
host: legalgodb.ctuok62cmn6i.ap-southeast-1.rds.amazonaws.com
|
||||||
port: 5432
|
port: 5432
|
||||||
driver: postgres
|
driver: postgres
|
||||||
db: legalgonews_prod
|
db: legalgonews
|
||||||
username: legalgo_admin
|
username: legalgo_admin
|
||||||
password: "656ogwc0JlLEVQyHnT5RrrYa7762iBQQ"
|
password: "K4K!2Kg7cKW6H&4A2aBy2dFCRY3Sh"
|
||||||
ssl-mode: disable
|
ssl-mode: disable
|
||||||
max-idle-connections-in-second: 600
|
max-idle-connections-in-second: 600
|
||||||
max-open-connections-in-second: 600
|
max-open-connections-in-second: 600
|
||||||
@@ -22,18 +22,17 @@ postgresql:
|
|||||||
debug: false
|
debug: false
|
||||||
|
|
||||||
oss:
|
oss:
|
||||||
access_key_id: GTK7i3SVy9llQeGH0Htv
|
access_key_id: cf9a475e18bc7626cbdbf09709d82a64
|
||||||
access_key_secret: 2psmKXZFpevA9n5ntSDRMqFBpZuSz32dvtXjYclf
|
access_key_secret: 91f3321294d3e23035427a0ecb893ada
|
||||||
endpoint: news-cdn.legalgo.id
|
endpoint: sin1.contabostorage.com
|
||||||
bucket_name: uploads
|
bucket_name: legalgonews-dev
|
||||||
log_level: Error
|
log_level: Error
|
||||||
host_url: https://news-cdn.legalgo.id
|
host_url: https://sin1.contabostorage.com
|
||||||
public_url: https://news-cdn.legalgo.id
|
public_url: https://sin1.contabostorage.com/fda98c2228f246f29a7e466b86b3b9e7
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
host: red-d046l42dbo4c73ea9iag
|
host: legalgocache-qn8fuh.serverless.apse1.cache.amazonaws.com
|
||||||
port: 6379
|
port: 6379
|
||||||
password: 7cZvu08JKuO9MPNxBb97tZCVNj0ZGNp2
|
|
||||||
db: 5
|
db: 5
|
||||||
ssl: false
|
ssl: false
|
||||||
max-idle-connections-in-second: 600
|
max-idle-connections-in-second: 600
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ func (r *OssRepositoryImpl) GetPublicURL(fileName string) string {
|
|||||||
if fileName == "" {
|
if fileName == "" {
|
||||||
return ""
|
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 {
|
func (r *OssRepositoryImpl) DeleteObject(ctx context.Context, fileName string) error {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package redisaccessor
|
package redisaccessor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/tls"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"legalgo-BE-go/config"
|
"legalgo-BE-go/config"
|
||||||
|
|
||||||
@@ -17,19 +16,11 @@ func Get() *redis.Client {
|
|||||||
func New(cfg *config.Config) *redis.Client {
|
func New(cfg *config.Config) *redis.Client {
|
||||||
addr := fmt.Sprintf("%s:%s", cfg.Redis.Host, cfg.Redis.Port)
|
addr := fmt.Sprintf("%s:%s", cfg.Redis.Host, cfg.Redis.Port)
|
||||||
|
|
||||||
options := &redis.Options{
|
redisClient = redis.NewClient(&redis.Options{
|
||||||
Addr: addr,
|
Addr: addr,
|
||||||
Password: cfg.Redis.Password,
|
Password: cfg.Redis.Password,
|
||||||
DB: cfg.Redis.DB,
|
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
|
return redisClient
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
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
|
||||||
|
Metadata:
|
||||||
|
BuildMethod: go1.x
|
||||||
Reference in New Issue
Block a user