-
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.
사용자 데이터 CR, kakao oauth 인증 기능 및 jwt token을 발급할 수 있는 기능 추가 (#11)
* add: local에서 redis를 사용할 수 있도록 컨테이너 추가 * add: redis 버전 지정 * add: 의존성 정보 추가 * use: redis * init: redis * add: 테스트 코드 추가 * add: mysql * add: mysql data 제외 * use: gorm.io/gorm * add: mysql query test * del: 이전 프로젝트 파일 제거 * init * del: 사용되지 않는 코드 삭제 * edit: 모듈 경로 해당 repo로 변경 * doce: 문서화 반영 * up: config 값 모두 환경변수화 * add: 서버 도메인 환경변수화 * add: dev config랑 동기화 * up: 스웨거 관련 환경변수 추가 * up: qa 환경에서 환경변수 주입받을 수 있도록 k8s 수정 완료 * up: 환경 변수 정리 add: local 이외 환경은 https만 스웨거로 볼 수 있도록 수정 * up: 환경변수 순서 변경 * docs: 문서 보강 * up: prod 환경 변수 주입 코드
- Loading branch information
Showing
54 changed files
with
4,357 additions
and
196 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,5 @@ | ||
# common | ||
.git | ||
LICENSE | ||
*.md | ||
*.log |
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,54 +1,11 @@ | ||
# Created by https://www.toptal.com/developers/gitignore/api/go,macos | ||
# Edit at https://www.toptal.com/developers/gitignore?templates=go,macos | ||
# vscode-go 디버깅 파일 | ||
__debug_bin | ||
|
||
### Go ### | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
# codegangsta/gin hot reloading시 발생하는 파일 | ||
gin-bin | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
# docker | ||
docker/**/data | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
|
||
### Go Patch ### | ||
/vendor/ | ||
/Godeps/ | ||
|
||
### macOS ### | ||
# General | ||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
|
||
# Icon must end with two \r | ||
Icon | ||
|
||
|
||
# Thumbnails | ||
._* | ||
|
||
# Files that might appear in the root of a volume | ||
.DocumentRevisions-V100 | ||
.fseventsd | ||
.Spotlight-V100 | ||
.TemporaryItems | ||
.Trashes | ||
.VolumeIcon.icns | ||
.com.apple.timemachine.donotpresent | ||
|
||
# Directories potentially created on remote AFP share | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk | ||
|
||
# End of https://www.toptal.com/developers/gitignore/api/go,macos | ||
# 기타 | ||
.DS_STORE |
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,15 +1,22 @@ | ||
{ | ||
// IntelliSense를 사용하여 가능한 특성에 대해 알아보세요. | ||
// 기존 특성에 대한 설명을 보려면 가리킵니다. | ||
// 자세한 내용을 보려면 https://go.microsoft.com/fwlink/?linkid=830387을(를) 방문하세요. | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Launch Package", | ||
"name": "Attach to Gin", | ||
"type": "go", | ||
"request": "attach", | ||
"mode": "local", | ||
"processId": "gin-bin" | ||
}, | ||
{ | ||
"name": "Server", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "auto", | ||
"program": "${workspaceFolder}" | ||
"program": "${workspaceFolder}", | ||
"env": { | ||
"GO_ENV": "development" | ||
} | ||
} | ||
] | ||
} |
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,17 @@ | ||
{ | ||
// json에 주석을 사용할 수 있도록 기본 포멧터 변경 | ||
"files.associations": { | ||
"*.json": "jsonc" | ||
}, | ||
|
||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.formatOnSave": true, | ||
|
||
"[go]": { | ||
"editor.defaultFormatter": "golang.go" | ||
}, | ||
// [handler에 중단점을 찍을 때마다 디버깅이 중지되어서 일단은 레거시 디버깅 사용](https://stackoverflow.com/questions/69156581/does-the-execution-have-to-keep-stopping-to-set-a-breakpoint) | ||
"go.delveConfig": { | ||
"debugAdapter": "legacy" | ||
} | ||
} |
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,48 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "container up", | ||
"type": "shell", | ||
"command": "docker-compose", | ||
"args": ["up", "-d"], | ||
"options": { | ||
"cwd": "${workspaceFolder}" | ||
} | ||
}, | ||
{ | ||
"label": "container stop", | ||
"type": "shell", | ||
"command": "docker-compose", | ||
"args": ["stop"], | ||
"options": { | ||
"cwd": "${workspaceFolder}" | ||
} | ||
}, | ||
{ | ||
"label": "swag docs update", | ||
"type": "shell", | ||
"command": "swag", | ||
"args": ["i"], | ||
"options": { | ||
"cwd": "${workspaceFolder}", | ||
"env": { | ||
"PATH": "${env:GOPATH}/bin:${env:PATH}" | ||
} | ||
} | ||
}, | ||
{ | ||
"label": "live reloading gin server", | ||
"type": "shell", | ||
"command": "gin", | ||
"args": ["--port", "5100", "--immediate", "--notifications"], | ||
"options": { | ||
"cwd": "${workspaceFolder}", | ||
"env": { | ||
"PATH": "${env:GOPATH}/bin:${env:PATH}", | ||
"GO_ENV": "development" | ||
} | ||
} | ||
} | ||
] | ||
} |
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,25 +1,31 @@ | ||
# [해당 문서를 참고하였습니다](https://thesorauniverse.com/posts/kr/golang/making-golang-docker-img-best-practices/) | ||
FROM golang:1.16.3 AS builder | ||
FROM golang:1.16.3 AS golang-builder | ||
|
||
ENV GO111MODULE=on \ | ||
CGO_ENABLED=0 \ | ||
GOOS=linux \ | ||
GOARCH=amd64 | ||
ENV GO111MODULE=on | ||
ENV CGO_ENABLED=0 | ||
ENV GOOS=linux | ||
ENV GOARCH=amd64 | ||
|
||
WORKDIR /build | ||
|
||
COPY . . | ||
|
||
COPY ./go.mod ./ | ||
COPY ./go.sum ./ | ||
RUN go mod download | ||
|
||
RUN go build -o main . | ||
COPY ./ ./ | ||
RUN go build -o main ./ | ||
|
||
WORKDIR /dist | ||
|
||
RUN cp /build/main . | ||
RUN cp /build/main ./ | ||
RUN cp /build/configs/config.prod.json ./ | ||
|
||
FROM scratch | ||
|
||
COPY --from=builder /dist/main . | ||
LABEL author="parkgang[Kyungeun Park]<[email protected]>" | ||
LABEL version="0.1.0" | ||
|
||
ENV GO_ENV=production | ||
|
||
COPY --from=golang-builder /dist/main ./ | ||
COPY --from=golang-builder /dist/config.prod.json ./configs/config.prod.json | ||
|
||
EXPOSE 8080 | ||
|
||
ENTRYPOINT ["/main"] |
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,26 @@ | ||
{ | ||
"STAGES": "local", | ||
|
||
"SERVER_PORT": "8080", | ||
|
||
"SWAGGER_HOSTNAME": "localhost", | ||
"SWAGGER_PORT": "8080", | ||
|
||
"KAKAO_REST_API_KEY": "", | ||
"KAKAO_REDIRECT_URI": "", | ||
|
||
"JWT_ACCESS_SECRET": "", | ||
"JWT_REFRESH_SECRET": "", | ||
"AUTH_REDIRECT_URL": "http://localhost:3000/auth-end", | ||
|
||
"MYSQL_MASTER_HOST": "localhost", | ||
"MYSQL_MASTER_PORT": "3306", | ||
"MYSQL_MASTER_USERNAME": "root", | ||
"MYSQL_MASTER_PASSWORD": "example", | ||
"MYSQL_MASTER_DATABASE": "belf", | ||
|
||
"REDIS_HOST": "localhost", | ||
"REDIS_PORT": "6379", | ||
"REDIS_PASSWORD": "", | ||
"REDIS_DATABASE": 0 | ||
} |
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,37 @@ | ||
package configs | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/gin-gonic/gin" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
const ( | ||
development = "development" | ||
production = "production" | ||
) | ||
|
||
func init() { | ||
viper.AutomaticEnv() | ||
// 절대 경로를 기준으로 작성해야 합니다. | ||
viper.AddConfigPath("./configs") | ||
|
||
switch os.Getenv("GO_ENV") { | ||
case "": | ||
panic("GO_ENV 값이 지정되지 않았습니다.") | ||
case development: | ||
viper.SetConfigName("config.dev") | ||
gin.SetMode(gin.DebugMode) | ||
case production: | ||
viper.SetConfigName("config.prod") | ||
gin.SetMode(gin.ReleaseMode) | ||
default: | ||
panic("알려지지 않은 GO_ENV 값 입니다.") | ||
} | ||
|
||
err := viper.ReadInConfig() | ||
if err != nil { | ||
panic("config 값 읽기에 실패하였습니다.\n\t" + err.Error()) | ||
} | ||
} |
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,26 @@ | ||
{ | ||
"STAGES": "local", | ||
|
||
"SERVER_PORT": "8080", | ||
|
||
"SWAGGER_HOSTNAME": "localhost", | ||
"SWAGGER_PORT": "8080", | ||
|
||
"KAKAO_REST_API_KEY": "", | ||
"KAKAO_REDIRECT_URI": "", | ||
|
||
"JWT_ACCESS_SECRET": "", | ||
"JWT_REFRESH_SECRET": "", | ||
"AUTH_REDIRECT_URL": "http://localhost:3000/auth-end", | ||
|
||
"MYSQL_MASTER_HOST": "host.docker.internal", | ||
"MYSQL_MASTER_PORT": "3306", | ||
"MYSQL_MASTER_USERNAME": "", | ||
"MYSQL_MASTER_PASSWORD": "", | ||
"MYSQL_MASTER_DATABASE": "belf", | ||
|
||
"REDIS_HOST": "host.docker.internal", | ||
"REDIS_PORT": "6379", | ||
"REDIS_PASSWORD": "", | ||
"REDIS_DATABASE": 0 | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.