-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
422 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
GO = docker run --rm -e GOOS=linux -e GOARCH=amd64 -v $(PWD):/usr/src/app -w /usr/src/app golang:1.13 go | ||
R = docker run --rm --name notes --network dev -e APP_ENV=dev -e GOOS=linux -e GOARCH=amd64 -v $(PWD):/usr/src/app -w /usr/src/app golang:1.13 go | ||
|
||
.PHONY: clean test build lambda_build lambda_artifact lambda_deploy deploy | ||
|
||
build: clean test lambda_build lambda_artifact | ||
|
||
run: | ||
$(R) run ./cmd/gin.go | ||
|
||
test: | ||
@echo "Testing..." | ||
$(GO) test cmd/gin.go | ||
|
||
|
||
lambda_build: | ||
@echo "Building..." | ||
$(GO) build -o build/out/notes_api cmd/lambda.go | ||
|
||
|
||
lambda_artifact: | ||
zip -j build/out/main.zip build/out/notes_api | ||
zip build/out/main.zip config/*.yml data/key.pem | ||
|
||
|
||
deploy: | ||
@echo "Deploying..." | ||
aws lambda update-function-code --function-name NotesAPI \ | ||
--zip-file "fileb://build/out/main.zip" | ||
|
||
|
||
deploy_test: | ||
curl https://finance-api.kvslab.icu/info | ||
|
||
|
||
clean: | ||
rm build/out/notes_api || true | ||
rm build/out/main.zip || true |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/ksopin/notes/internal/http" | ||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
func main() { | ||
log.SetFormatter(&log.JSONFormatter{}) | ||
err := http.Run() | ||
if err != nil { | ||
panic(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package main | ||
|
||
import ginlambda "github.com/ksopin/notes/internal/lambda" | ||
|
||
func main() { | ||
err := ginlambda.Run() | ||
if err != nil { | ||
panic(err) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
app: | ||
project_name: Notes API | ||
code: notes-api | ||
env: dev | ||
version: 1.0.0 | ||
db: | ||
server: mysql_server | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
app: | ||
project_name: Notes API | ||
code: notes-api | ||
version: stage | ||
db: | ||
server: dev-db.c41pzugyuh79.eu-west-1.rds.amazonaws.com | ||
username: appnotes | ||
password: Bo1c6HTgo7YCNig9 | ||
name: notes_stage | ||
http: | ||
enabled: true | ||
port: 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,36 @@ | ||
package app | ||
|
||
type Config struct{ | ||
import ( | ||
"github.com/ksopin/notes/pkg/db" | ||
log "github.com/sirupsen/logrus" | ||
"gopkg.in/yaml.v2" | ||
"io/ioutil" | ||
) | ||
type Config struct { | ||
App *AppConfig | ||
Db *db.Config | ||
Http *struct { | ||
Enabled bool | ||
Port int | ||
} | ||
} | ||
|
||
type AppConfig struct{ | ||
ProjectName string `yaml:"project_name"` | ||
Code string | ||
Env string | ||
Version string | ||
} | ||
} | ||
|
||
func GetConfig(configFile string) *Config { | ||
yamlFile, err := ioutil.ReadFile(configFile) | ||
if err != nil { | ||
log.Fatalf("yamlFile.Get %+v ", err) | ||
} | ||
c := &Config{} | ||
err = yaml.Unmarshal(yamlFile, c) | ||
if err != nil { | ||
log.Fatalf("Unmarshal: %+v", err) | ||
} | ||
|
||
return c | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.