diff --git a/Makefile b/Makefile index fd6ea3a..e5fcf59 100644 --- a/Makefile +++ b/Makefile @@ -1,22 +1,11 @@ -# Go parameters -GOCMD=go -GOBUILD=$(GOCMD) build -GOCLEAN=$(GOCMD) clean -GOTEST=$(GOCMD) test -GOGET=$(GOCMD) get - -deps: - $(GOGET) -v ./... -run-auth: - $(GOCMD) run ./auth/cmd/v1/main.go http -run-shortener-http: - $(GOCMD) run ./shortener/cmd/v1/main.go http -run-shortener-grpc: - $(GOCMD) run ./shortener/cmd/v1/main.go grpc -run-shortener-consumer: - $(GOCMD) run ./shortener/cmd/v1/main.go consumer -run-user: - $(GOCMD) run ./user/cmd/v1/main.go http +build: + docker-compose build +run: + docker-compose up -d --build --force-recreate +stop: + docker-compose down +remove: + docker-compose down -v -.PHONY: deps run-auth run-shortener-http run-shortener-grpc run-shortener-consumer run-user +.PHONY: build run stop remove diff --git a/README.md b/README.md index 687f422..7fb3ad2 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Revamped [Last Projects URL Shortener API's](https://github.com/PickHD/singkatin ## Architect Overview : ![ERD](https://raw.github.com/PickHD/singkatin-revamp/master/arch_singkatin_revamp.png) -## Whats Changed? +## Whats Changed? : 1. From Monolith to Microservices 2. Scalable & Maintainable Codes 3. Become Asynchronous Operation using Messaging Queues (RabbitMQ) @@ -22,5 +22,24 @@ Revamped [Last Projects URL Shortener API's](https://github.com/PickHD/singkatin 3. Redis 4. RabbitMQ 5. GRPC +6. Docker +## Setup : +_(make sure docker & docker-compose installed)_ +1. To build all services, run command : + ``` + $ make build + ``` +2. You can build & run all services in background using command : + ``` + $ make run + ``` +3. If you want to stop all services then run : + ``` + $ make stop + ``` +4. Last if want to stop & remove entire services then run : + ``` + $ make remove + ``` \ No newline at end of file diff --git a/auth/build/http/Dockerfile b/auth/build/http/Dockerfile new file mode 100644 index 0000000..43fab1f --- /dev/null +++ b/auth/build/http/Dockerfile @@ -0,0 +1,31 @@ +FROM golang:1.20.3 AS builder +LABEL maintainer="taufikjanuar35@gmail.com" + +RUN go version + +WORKDIR /auth +COPY ./auth/go.mod ./ +COPY ./auth/go.sum ./ + +RUN go mod download + +COPY ./auth . + +# Build Go App +RUN CGO_ENABLED=0 GOOS=linux go build -o auth-service ./cmd/v1 + +FROM alpine:3.11.3 + +WORKDIR /app + +RUN mkdir cmd docs + +COPY --from=builder ./auth/cmd/ ./cmd +COPY --from=builder ./auth/docs/ ./docs +COPY --from=builder ./auth/auth-service . + +# Expose port +EXPOSE 8080 + +# Command to run the executeable +ENTRYPOINT ["./auth-service","http"] diff --git a/auth/internal/v1/config/.env b/auth/cmd/v1/.env similarity index 88% rename from auth/internal/v1/config/.env rename to auth/cmd/v1/.env index f0700db..dd9129a 100644 --- a/auth/internal/v1/config/.env +++ b/auth/cmd/v1/.env @@ -1,6 +1,6 @@ APP_PORT=8080 -DB_HOST=localhost +DB_HOST=mongo DB_PORT=27017 DB_NAME=singkatin DB_COLLECTION_USERS=users diff --git a/auth/cmd/v1/main.go b/auth/cmd/v1/main.go index 879df73..ce11d54 100644 --- a/auth/cmd/v1/main.go +++ b/auth/cmd/v1/main.go @@ -29,7 +29,10 @@ const ( // @BasePath /v1 // @Schemes http func main() { - _ = godotenv.Load("./auth/internal/v1/config/.env") + err := godotenv.Load("./cmd/v1/.env") + if err != nil { + panic(err) + } runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/auth/go.mod b/auth/go.mod index c862a36..2aaae5d 100644 --- a/auth/go.mod +++ b/auth/go.mod @@ -2,21 +2,22 @@ module github.com/PickHD/singkatin-revamp/auth go 1.20 -require github.com/swaggo/gin-swagger v1.6.0 +require ( + github.com/golang-jwt/jwt v3.2.2+incompatible + github.com/joho/godotenv v1.5.1 + github.com/pkg/errors v0.9.1 + github.com/swaggo/gin-swagger v1.6.0 + go.mongodb.org/mongo-driver v1.11.6 +) require ( - github.com/golang-jwt/jwt/v4 v4.5.0 // indirect github.com/golang/snappy v0.0.4 // indirect - github.com/joho/godotenv v1.5.1 // indirect github.com/klauspost/compress v1.16.5 // indirect github.com/montanaflynn/stats v0.7.0 // indirect - github.com/pkg/errors v0.9.1 // indirect - github.com/xakep666/mongo-migrate v0.2.1 // indirect github.com/xdg-go/pbkdf2 v1.0.0 // indirect github.com/xdg-go/scram v1.1.2 // indirect github.com/xdg-go/stringprep v1.0.4 // indirect github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect - go.mongodb.org/mongo-driver v1.11.5 // indirect golang.org/x/sync v0.1.0 // indirect ) @@ -27,7 +28,7 @@ require ( github.com/bytedance/sonic v1.8.8 // indirect github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect github.com/gin-contrib/sse v0.1.0 // indirect - github.com/gin-gonic/gin v1.9.0 // indirect + github.com/gin-gonic/gin v1.9.0 github.com/go-openapi/jsonpointer v0.19.5 // indirect github.com/go-openapi/jsonreference v0.19.6 // indirect github.com/go-openapi/spec v0.20.4 // indirect @@ -45,13 +46,13 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pelletier/go-toml/v2 v2.0.7 // indirect - github.com/sirupsen/logrus v1.9.0 // indirect + github.com/sirupsen/logrus v1.9.0 github.com/swaggo/files v1.0.1 - github.com/swaggo/swag v1.8.12 // indirect + github.com/swaggo/swag v1.8.12 github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.11 // indirect golang.org/x/arch v0.3.0 // indirect - golang.org/x/crypto v0.8.0 // indirect + golang.org/x/crypto v0.8.0 golang.org/x/net v0.9.0 // indirect golang.org/x/sys v0.7.0 // indirect golang.org/x/text v0.9.0 // indirect diff --git a/auth/go.sum b/auth/go.sum index f9257e5..e7481ab 100644 --- a/auth/go.sum +++ b/auth/go.sum @@ -12,7 +12,9 @@ github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhD github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.9.0 h1:OjyFBKICoexlu99ctXNR2gg+c5pKrKMuyjgARg9qeY8= @@ -27,24 +29,23 @@ github.com/go-openapi/spec v0.20.4/go.mod h1:faYFR1CvsJZ0mNsmsphTMSoRrNV3TEDoAM7 github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM= github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= +github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/validator/v10 v10.13.0 h1:cFRQdfaSMCOSfGCCLB20MHvuoHb/s5G8L5pu2ppK5AQ= github.com/go-playground/validator/v10 v10.13.0/go.mod h1:dwu7+CG8/CtBiJFZDz4e+5Upb6OLw04gtBYw0mcG/z4= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= -github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= -github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= +github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= @@ -53,16 +54,17 @@ github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8Hm github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.16.5 h1:IFV2oUNUzZaz+XyusxpLzpzS8Pt5rh0Z16For/djlyI= github.com/klauspost/compress v1.16.5/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk= github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= @@ -77,16 +79,16 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/montanaflynn/stats v0.7.0 h1:r3y12KyNxj/Sb/iOE46ws+3mS1+MZca1wlHQFPsY/JU= github.com/montanaflynn/stats v0.7.0/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/pelletier/go-toml/v2 v2.0.7 h1:muncTPStnKRos5dpVKULv2FVd4bMOhNePj9CjgDb8Us= github.com/pelletier/go-toml/v2 v2.0.7/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= @@ -99,6 +101,7 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/swaggo/files v1.0.1 h1:J1bVJ4XHZNq0I46UU90611i9/YzdrF7x92oX1ig5IdE= github.com/swaggo/files v1.0.1/go.mod h1:0qXmMNH6sXNf+73t65aKeB+ApmgxdnkQzVTAj2uaMUg= @@ -106,47 +109,37 @@ github.com/swaggo/gin-swagger v1.6.0 h1:y8sxvQ3E20/RCyrXeFfg60r6H0Z+SwpTjMYsMm+z github.com/swaggo/gin-swagger v1.6.0/go.mod h1:BG00cCEy294xtVpyIAHG6+e2Qzj/xKlRdOqDkvq0uzo= github.com/swaggo/swag v1.8.12 h1:pctzkNPu0AlQP2royqX3apjKCQonAnf7KGoxeO4y64w= github.com/swaggo/swag v1.8.12/go.mod h1:lNfm6Gg+oAq3zRJQNEMBE66LIJKM44mxFqhEEgy2its= -github.com/tidwall/pretty v0.0.0-20190325153808-1166b9ac2b65/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= +github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= -github.com/xakep666/mongo-migrate v0.2.1 h1:pRK966a44ujuGMEl73MOzv4MajcH8Q6MWo+TBlxjhvs= -github.com/xakep666/mongo-migrate v0.2.1/go.mod h1:pVQysP+es2wX4TaeVd7zLkRZhKMcBqcC/KRyLms6Eyk= github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= -github.com/xdg-go/scram v1.1.1 h1:VOMT+81stJgXW3CpHyqHN3AXDYIMsx56mEFrB37Mb/E= github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g= github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY= github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4= -github.com/xdg-go/stringprep v1.0.3 h1:kdwGpVNwPFtjs98xCGkHjQtGKh86rDcRZN17QEMCOIs= github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8= github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8= github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM= -github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= -github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= -github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA= github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a h1:fZHgsYlfvtyqToslyjUt3VOPF4J7aK/3MPcK7xp3PDk= github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a/go.mod h1:ul22v+Nro/R083muKhosV54bj5niojjWZvU8xrevuH4= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -go.mongodb.org/mongo-driver v1.0.2/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= -go.mongodb.org/mongo-driver v1.11.4 h1:4ayjakA013OdpGyL2K3ZqylTac/rMjrJOMZ1EHizXas= -go.mongodb.org/mongo-driver v1.11.4/go.mod h1:PTSz5yu21bkT/wXpkS7WR5f0ddqw5quethTUn9WM+2g= -go.mongodb.org/mongo-driver v1.11.5 h1:CLrb1a22ddViSnnPCzGT4+PGrOJsUXI/9SWj8N1uHCM= -go.mongodb.org/mongo-driver v1.11.5/go.mod h1:PTSz5yu21bkT/wXpkS7WR5f0ddqw5quethTUn9WM+2g= +go.mongodb.org/mongo-driver v1.11.6 h1:XM7G6PjiGAO5betLF13BIa5TlLUUE3uJ/2Ox3Lz1K+o= +go.mongodb.org/mongo-driver v1.11.6/go.mod h1:G9TgswdsWjX4tmDA5zfs2+6AEPpYJwqblyjsfuh8oXY= golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.8.0 h1:pd9TJtTueMTVQXzk8E2XESSMQDj/U7OUu0PqJqPXQjQ= golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= @@ -179,7 +172,6 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9sn golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= @@ -193,12 +185,14 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4= golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..453b4d3 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,126 @@ +version: '3.9' + +services: + mongo: + image: mongo + container_name: mongo + ports: + - '27017:27017' + networks: + - singkatin-dev + volumes: + - mongo_data:/data/db + redis: + image: redis + container_name: redis + ports: + - '6379:6379' + networks: + - singkatin-dev + volumes: + - redis_data:/data + amqp: + image: rabbitmq:3-management-alpine + container_name: amqp + ports: + - '5672:5672' + - '15672:15672' + networks: + - singkatin-dev + volumes: + - ~/.docker-conf/rabbitmq/data/:/var/lib/rabbitmq + auth-service-http: + container_name: auth-service-http + build: + context: . + dockerfile: ./auth/build/http/Dockerfile + ports: + - '8080:8080' + command: auth-service http + networks: + - singkatin-dev + restart: unless-stopped + depends_on: + - mongo + links: + - mongo + shortener-service-http: + container_name: shortener-service-http + build: + context: . + dockerfile: ./shortener/build/http/Dockerfile + ports: + - '8081:8081' + command: shortener-service http + networks: + - singkatin-dev + restart: unless-stopped + depends_on: + - mongo + - redis + - amqp + links: + - mongo + - redis + - amqp + shortener-service-grpc: + container_name: shortener-service-grpc + build: + context: . + dockerfile: ./shortener/build/grpc/Dockerfile + ports: + - '9091:9091' + command: shortener-service grpc + networks: + - singkatin-dev + restart: unless-stopped + depends_on: + - mongo + - redis + - amqp + links: + - mongo + - redis + - amqp + shortener-service-consumer: + container_name: shortener-service-consumer + build: + context: . + dockerfile: ./shortener/build/consumer/Dockerfile + command: shortener-service consumer + networks: + - singkatin-dev + restart: unless-stopped + depends_on: + - mongo + - redis + - amqp + links: + - mongo + - redis + - amqp + user-service-http: + container_name: user-service-http + build: + context: . + dockerfile: ./user/build/http/Dockerfile + ports: + - '8082:8082' + command: user-service http + networks: + - singkatin-dev + restart: unless-stopped + depends_on: + - mongo + - redis + - amqp + links: + - mongo + - redis + - amqp +networks: + singkatin-dev: + driver: bridge +volumes: + mongo_data: + redis_data: \ No newline at end of file diff --git a/go.work.sum b/go.work.sum index 0049b16..42afbeb 100644 --- a/go.work.sum +++ b/go.work.sum @@ -1,4 +1,160 @@ +cloud.google.com/go v0.110.0 h1:Zc8gqp3+a9/Eyph2KDmcGaPtbKRIoqq4YTlL4NMD0Ys= +cloud.google.com/go/accessapproval v1.6.0 h1:x0cEHro/JFPd7eS4BlEWNTMecIj2HdXjOVB5BtvwER0= +cloud.google.com/go/accesscontextmanager v1.6.0 h1:r7DpDlWkCMtH/w+gu6Yq//EeYgNWSUbR1+n8ZYr4YWk= +cloud.google.com/go/aiplatform v1.35.0 h1:8frB0cIswlhVnYnGrMr+JjZaNC7DHZahvoGHpU9n+RY= +cloud.google.com/go/analytics v0.18.0 h1:uN80RHQeT2jGA3uAFDZSBnKdful4bFw0IHJV6t3EkqU= +cloud.google.com/go/apigateway v1.5.0 h1:ZI9mVO7x3E9RK/BURm2p1aw9YTBSCQe3klmyP1WxWEg= +cloud.google.com/go/apigeeconnect v1.5.0 h1:sWOmgDyAsi1AZ48XRHcATC0tsi9SkPT7DA/+VCfkaeA= +cloud.google.com/go/apigeeregistry v0.5.0 h1:BwTPDPTBlYIoQGiwtRUsNFRDZ24cT/02Xb3yFH614YQ= +cloud.google.com/go/apikeys v0.5.0 h1:+77+/BhFuU476/s78kYiWHObxaYBHsC6Us+Gd7W9pJ4= +cloud.google.com/go/appengine v1.6.0 h1:uTDtjzuHpig1lrf8lycxNSKrthiTDgXnadu+WxYEKxQ= +cloud.google.com/go/area120 v0.7.1 h1:ugckkFh4XkHJMPhTIx0CyvdoBxmOpMe8rNs4Ok8GAag= +cloud.google.com/go/artifactregistry v1.11.2 h1:G9kjfHsDto5AdKK93hkHWHsY9Oe+6Nv66i7o/KgUO8E= +cloud.google.com/go/asset v1.11.1 h1:yObuRcVfexhYQuIWbjNt+9PVPikXIRhERXZxga7qAAY= +cloud.google.com/go/assuredworkloads v1.10.0 h1:VLGnVFta+N4WM+ASHbhc14ZOItOabDLH1MSoDv+Xuag= +cloud.google.com/go/automl v1.12.0 h1:50VugllC+U4IGl3tDNcZaWvApHBTrn/TvyHDJ0wM+Uw= +cloud.google.com/go/baremetalsolution v0.5.0 h1:2AipdYXL0VxMboelTTw8c1UJ7gYu35LZYUbuRv9Q28s= +cloud.google.com/go/batch v0.7.0 h1:YbMt0E6BtqeD5FvSv1d56jbVsWEzlGm55lYte+M6Mzs= +cloud.google.com/go/beyondcorp v0.4.0 h1:qwXDVYf4fQ9DrKci8/40X1zaKYxzYK07vSdPeI9mEQw= +cloud.google.com/go/bigquery v1.48.0 h1:u+fhS1jJOkPO9vdM84M8HO5VznTfVUicBeoXNKD26ho= +cloud.google.com/go/billing v1.12.0 h1:k8pngyiI8uAFhVAhH5+iXSa3Me406XW17LYWZ/3Fr84= +cloud.google.com/go/binaryauthorization v1.5.0 h1:d3pMDBCCNivxt5a4eaV7FwL7cSH0H7RrEnFrTb1QKWs= +cloud.google.com/go/certificatemanager v1.6.0 h1:5C5UWeSt8Jkgp7OWn2rCkLmYurar/vIWIoSQ2+LaTOc= +cloud.google.com/go/channel v1.11.0 h1:/ToBJYu+7wATtd3h8T7hpc4+5NfzlJMDRZjPLIm4EZk= +cloud.google.com/go/cloudbuild v1.7.0 h1:osBOHQJqLPqNfHfkRQXz6sCKAIEKRrupA9NaAGiLN4s= +cloud.google.com/go/clouddms v1.5.0 h1:E7v4TpDGUyEm1C/4KIrpVSOCTm0P6vWdHT0I4mostRA= +cloud.google.com/go/cloudtasks v1.9.0 h1:Cc2/20hMhGLV2pBGk/i6zNY+eTT9IsV3mrK6TKBu3gs= +cloud.google.com/go/compute v1.18.0 h1:FEigFqoDbys2cvFkZ9Fjq4gnHBP55anJ0yQyau2f9oY= +cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= +cloud.google.com/go/contactcenterinsights v1.6.0 h1:jXIpfcH/VYSE1SYcPzO0n1VVb+sAamiLOgCw45JbOQk= +cloud.google.com/go/container v1.13.1 h1:q8lTpyAsjcJZQCjGI8JJfcOG4ixl998vwe6TAgQROcM= +cloud.google.com/go/containeranalysis v0.7.0 h1:kw0dDRJPIN8L50Nwm8qa5VuGKPrbVup5lM3ULrvuWrg= +cloud.google.com/go/datacatalog v1.12.0 h1:3uaYULZRLByPdbuUvacGeqneudztEM4xqKQsBcxbDnY= +cloud.google.com/go/dataflow v0.8.0 h1:eYyD9o/8Nm6EttsKZaEGD84xC17bNgSKCu0ZxwqUbpg= +cloud.google.com/go/dataform v0.6.0 h1:HBegGOzStIXPWo49FaVTzJOD4EPo8BndPFBUfsuoYe0= +cloud.google.com/go/datafusion v1.6.0 h1:sZjRnS3TWkGsu1LjYPFD/fHeMLZNXDK6PDHi2s2s/bk= +cloud.google.com/go/datalabeling v0.7.0 h1:ch4qA2yvddGRUrlfwrNJCr79qLqhS9QBwofPHfFlDIk= +cloud.google.com/go/dataplex v1.5.2 h1:uSkmPwbgOWp3IFtCVEM0Xew80dczVyhNXkvAtTapRn8= +cloud.google.com/go/dataproc v1.12.0 h1:W47qHL3W4BPkAIbk4SWmIERwsWBaNnWm0P2sdx3YgGU= +cloud.google.com/go/dataqna v0.7.0 h1:yFzi/YU4YAdjyo7pXkBE2FeHbgz5OQQBVDdbErEHmVQ= +cloud.google.com/go/datastore v1.10.0 h1:4siQRf4zTiAVt/oeH4GureGkApgb2vtPQAtOmhpqQwE= +cloud.google.com/go/datastream v1.6.0 h1:v6j8C4p0TfXA9Wcea3iH7ZUm05Cx4BiPsH4vEkH7A9g= +cloud.google.com/go/deploy v1.6.0 h1:hdXxUdVw+NOrCQeqg9eQPB3hF1mFEchoS3h+K4IAU9s= +cloud.google.com/go/dialogflow v1.31.0 h1:TwmxDsdFcQdExfShoLRlTtdPTor8qSxNu9KZ13o+TUQ= +cloud.google.com/go/dlp v1.9.0 h1:1JoJqezlgu6NWCroBxr4rOZnwNFILXr4cB9dMaSKO4A= +cloud.google.com/go/documentai v1.16.0 h1:tHZA9dB2xo3VaCP4JPxs5jHRntJnmg38kZ0UxlT/u90= +cloud.google.com/go/domains v0.8.0 h1:2ti/o9tlWL4N+wIuWUNH+LbfgpwxPr8J1sv9RHA4bYQ= +cloud.google.com/go/edgecontainer v0.3.0 h1:i57Q4zg9j8h4UQoKTD7buXbLCvofmmV8+8owwSmM3ew= +cloud.google.com/go/errorreporting v0.3.0 h1:kj1XEWMu8P0qlLhm3FwcaFsUvXChV/OraZwA70trRR0= +cloud.google.com/go/essentialcontacts v1.5.0 h1:gIzEhCoOT7bi+6QZqZIzX1Erj4SswMPIteNvYVlu+pM= +cloud.google.com/go/eventarc v1.10.0 h1:4cELkxrOYntz1VRNi2deLRkOr+R6u175kF4hUyd/4Ms= +cloud.google.com/go/filestore v1.5.0 h1:M/iQpbNJw+ELfEvFAW2mAhcHOn1HQQzIkzqmA4njTwg= +cloud.google.com/go/firestore v1.9.0 h1:IBlRyxgGySXu5VuW0RgGFlTtLukSnNkpDiEOMkQkmpA= +cloud.google.com/go/functions v1.10.0 h1:WC0JiI5ZBTPSgjzFccqZ8TMkhoPRpDClN99KXhHJp6I= +cloud.google.com/go/gaming v1.9.0 h1:7vEhFnZmd931Mo7sZ6pJy7uQPDxF7m7v8xtBheG08tc= +cloud.google.com/go/gkebackup v0.4.0 h1:za3QZvw6ujR0uyqkhomKKKNoXDyqYGPJies3voUK8DA= +cloud.google.com/go/gkeconnect v0.7.0 h1:gXYKciHS/Lgq0GJ5Kc9SzPA35NGc3yqu6SkjonpEr2Q= +cloud.google.com/go/gkehub v0.11.0 h1:C4p1ZboBOexyCgZSCq+QdP+xfta9+puxgHFy8cjbgYI= +cloud.google.com/go/gkemulticloud v0.5.0 h1:8I84Q4vl02rJRsFiinBxl7WCozfdLlUVBQuSrqr9Wtk= +cloud.google.com/go/gsuiteaddons v1.5.0 h1:1mvhXqJzV0Vg5Fa95QwckljODJJfDFXV4pn+iL50zzA= +cloud.google.com/go/iam v0.12.0 h1:DRtTY29b75ciH6Ov1PHb4/iat2CLCvrOm40Q0a6DFpE= +cloud.google.com/go/iap v1.6.0 h1:a6Heb3z12tUHJqXvmYqLhr7cWz3zzl566xtlbavD5Q0= +cloud.google.com/go/ids v1.3.0 h1:fodnCDtOXuMmS8LTC2y3h8t24U8F3eKWfhi+3LY6Qf0= +cloud.google.com/go/iot v1.5.0 h1:so1XASBu64OWGylrv5xjvsi6U+/CIR2KiRuZt+WLyKk= +cloud.google.com/go/kms v1.9.0 h1:b0votJQa/9DSsxgHwN33/tTLA7ZHVzfWhDCrfiXijSo= +cloud.google.com/go/language v1.9.0 h1:7Ulo2mDk9huBoBi8zCE3ONOoBrL6UXfAI71CLQ9GEIM= +cloud.google.com/go/lifesciences v0.8.0 h1:uWrMjWTsGjLZpCTWEAzYvyXj+7fhiZST45u9AgasasI= +cloud.google.com/go/logging v1.7.0 h1:CJYxlNNNNAMkHp9em/YEXcfJg+rPDg7YfwoRpMU+t5I= +cloud.google.com/go/longrunning v0.4.1 h1:v+yFJOfKC3yZdY6ZUI933pIYdhyhV8S3NpWrXWmg7jM= +cloud.google.com/go/managedidentities v1.5.0 h1:ZRQ4k21/jAhrHBVKl/AY7SjgzeJwG1iZa+mJ82P+VNg= +cloud.google.com/go/maps v0.6.0 h1:soPzd0NABgCOGZavyZCAKrJ9L1JAwg3To6n5kuMCm98= +cloud.google.com/go/mediatranslation v0.7.0 h1:anPxH+/WWt8Yc3EdoEJhPMBRF7EhIdz426A+tuoA0OU= +cloud.google.com/go/memcache v1.9.0 h1:8/VEmWCpnETCrBwS3z4MhT+tIdKgR1Z4Tr2tvYH32rg= +cloud.google.com/go/metastore v1.10.0 h1:QCFhZVe2289KDBQ7WxaHV2rAmPrmRAdLC6gbjUd3HPo= +cloud.google.com/go/monitoring v1.12.0 h1:+X79DyOP/Ny23XIqSIb37AvFWSxDN15w/ktklVvPLso= +cloud.google.com/go/networkconnectivity v1.10.0 h1:DJwVcr97sd9XPc9rei0z1vUI2ExJyXpA11DSi+Yh7h4= +cloud.google.com/go/networkmanagement v1.6.0 h1:8KWEUNGcpSX9WwZXq7FtciuNGPdPdPN/ruDm769yAEM= +cloud.google.com/go/networksecurity v0.7.0 h1:sAKgrzvEslukcwezyEIoXocU2vxWR1Zn7xMTp4uLR0E= +cloud.google.com/go/notebooks v1.7.0 h1:mMI+/ETVBmCZjdiSYYkN6VFgFTR68kh3frJ8zWvg6go= +cloud.google.com/go/optimization v1.3.1 h1:dj8O4VOJRB4CUwZXdmwNViH1OtI0WtWL867/lnYH248= +cloud.google.com/go/orchestration v1.6.0 h1:Vw+CEXo8M/FZ1rb4EjcLv0gJqqw89b7+g+C/EmniTb8= +cloud.google.com/go/orgpolicy v1.10.0 h1:XDriMWug7sd0kYT1QKofRpRHzjad0bK8Q8uA9q+XrU4= +cloud.google.com/go/osconfig v1.11.0 h1:PkSQx4OHit5xz2bNyr11KGcaFccL5oqglFPdTboyqwQ= +cloud.google.com/go/oslogin v1.9.0 h1:whP7vhpmc+ufZa90eVpkfbgzJRK/Xomjz+XCD4aGwWw= +cloud.google.com/go/phishingprotection v0.7.0 h1:l6tDkT7qAEV49MNEJkEJTB6vOO/onbSOcNtAT09HPuA= +cloud.google.com/go/policytroubleshooter v1.5.0 h1:/fRzv4eqv9PDCEL7nBgJiA1EZxhdKMQ4/JIfheCdUZI= +cloud.google.com/go/privatecatalog v0.7.0 h1:7d0gcifTV9As6zzBQo34ZsFiRRlENjD3kw0o3uHn+fY= +cloud.google.com/go/pubsub v1.28.0 h1:XzabfdPx/+eNrsVVGLFgeUnQQKPGkMb8klRCeYK52is= +cloud.google.com/go/pubsublite v1.6.0 h1:qh04RCSOnQDVHYmzT74ANu8WR9czAXG3Jl3TV4iR5no= +cloud.google.com/go/recaptchaenterprise/v2 v2.6.0 h1:E9VgcQxj9M3HS945E3Jb53qd14xcpHBaEG1LgQhnxW8= +cloud.google.com/go/recommendationengine v0.7.0 h1:VibRFCwWXrFebEWKHfZAt2kta6pS7Tlimsnms0fjv7k= +cloud.google.com/go/recommender v1.9.0 h1:ZnFRY5R6zOVk2IDS1Jbv5Bw+DExCI5rFumsTnMXiu/A= +cloud.google.com/go/redis v1.11.0 h1:JoAd3SkeDt3rLFAAxEvw6wV4t+8y4ZzfZcZmddqphQ8= +cloud.google.com/go/resourcemanager v1.5.0 h1:m2RQU8UzBCIO+wsdwoehpuyAaF1i7ahFhj7TLocxuJE= +cloud.google.com/go/resourcesettings v1.5.0 h1:8Dua37kQt27CCWHm4h/Q1XqCF6ByD7Ouu49xg95qJzI= +cloud.google.com/go/retail v1.12.0 h1:1Dda2OpFNzIb4qWgFZjYlpP7sxX3aLeypKG6A3H4Yys= +cloud.google.com/go/run v0.8.0 h1:monNAz/FXgo8A31aR9sbrsv+bEbqy6H/arSgLOfA2Fk= +cloud.google.com/go/scheduler v1.8.0 h1:NRzIXqVxpyoiyonpYOKJmVJ9iif/Acw36Jri+cVHZ9U= +cloud.google.com/go/secretmanager v1.10.0 h1:pu03bha7ukxF8otyPKTFdDz+rr9sE3YauS5PliDXK60= +cloud.google.com/go/security v1.12.0 h1:WIyVxhrdex1geaAV0pC/4yXy/sZdurjHXLzMopcjers= +cloud.google.com/go/securitycenter v1.18.1 h1:DRUo2MFSq3Kt0a4hWRysdMHcu2obPwnSQNgHfOuwR4Q= +cloud.google.com/go/servicecontrol v1.11.0 h1:iEiMJgD1bzRL9Zu4JYDQUWfqZ+kRLX8wWZSCMBK8Qzs= +cloud.google.com/go/servicedirectory v1.8.0 h1:DPvPdb6O/lg7xK+BFKlzZN+w6upeJ/bbfcUnnqU66b8= +cloud.google.com/go/servicemanagement v1.6.0 h1:flWoX0eJy21+34I/7HPUbpr6xTHPVzws1xnecLFlUm0= +cloud.google.com/go/serviceusage v1.5.0 h1:fl1AGgOx7E2eyBmH5ofDXT9w8xGvEaEnHYyNYGkxaqg= +cloud.google.com/go/shell v1.6.0 h1:wT0Uw7ib7+AgZST9eCDygwTJn4+bHMDtZo5fh7kGWDU= +cloud.google.com/go/spanner v1.44.0 h1:fba7k2apz4aI0BE59/kbeaJ78dPOXSz2PSuBIfe7SBM= +cloud.google.com/go/speech v1.14.1 h1:x4ZJWhop/sLtnIP97IMmPtD6ZF003eD8hykJ0lOgEtw= +cloud.google.com/go/storagetransfer v1.7.0 h1:doREJk5f36gq7yJDJ2HVGaYTuQ8Nh6JWm+6tPjdfh+g= +cloud.google.com/go/talent v1.5.0 h1:nI9sVZPjMKiO2q3Uu0KhTDVov3Xrlpt63fghP9XjyEM= +cloud.google.com/go/texttospeech v1.6.0 h1:H4g1ULStsbVtalbZGktyzXzw6jP26RjVGYx9RaYjBzc= +cloud.google.com/go/tpu v1.5.0 h1:/34T6CbSi+kTv5E19Q9zbU/ix8IviInZpzwz3rsFE+A= +cloud.google.com/go/trace v1.8.0 h1:GFPLxbp5/FzdgTzor3nlNYNxMd6hLmzkE7sA9F0qQcA= +cloud.google.com/go/translate v1.6.0 h1:oBW4KVgcUq4OAXGdKEdyV7lqWiA3keQ3+8FKreAQv4g= +cloud.google.com/go/video v1.13.0 h1:FL+xG+4vgZASVIxcWACxneKPhFOnOX75GJhhTP7yUkQ= +cloud.google.com/go/videointelligence v1.10.0 h1:Uh5BdoET8XXqXX2uXIahGb+wTKbLkGH7s4GXR58RrG8= +cloud.google.com/go/vision/v2 v2.6.0 h1:WKt7VNhMLKaT9NmdisWnU2LVO5CaHvisssTaAqfV3dg= +cloud.google.com/go/vmmigration v1.5.0 h1:+2zAH2Di1FB02kAv8L9In2chYRP2Mw0bl41MiWwF+Fc= +cloud.google.com/go/vmwareengine v0.2.2 h1:ZM35wN4xuxDZSpKFypLMTsB02M+NEIZ2wr7/VpT3osw= +cloud.google.com/go/vpcaccess v1.6.0 h1:FOe6CuiQD3BhHJWt7E8QlbBcaIzVRddupwJlp7eqmn4= +cloud.google.com/go/webrisk v1.8.0 h1:IY+L2+UwxcVm2zayMAtBhZleecdIFLiC+QJMzgb0kT0= +cloud.google.com/go/websecurityscanner v1.5.0 h1:AHC1xmaNMOZtNqxI9Rmm87IJEyPaRkOxeI0gpAacXGk= +cloud.google.com/go/workflows v1.10.0 h1:FfGp9w0cYnaKZJhUOMqCOJCYT/WlvYBfTQhFWV3sRKI= +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= +github.com/census-instrumentation/opencensus-proto v0.4.1 h1:iKLQ0xPNFxR/2hzXZMrBo8f1j86j5WHzznCCQxV/b8g= +github.com/cncf/udpa/go v0.0.0-20220112060539-c52dc94e7fbe h1:QQ3GSy+MqSHxm/d8nCtnAiZdYFd45cYZPs8vOOIYKfk= +github.com/cncf/xds/go v0.0.0-20230310173818-32f1caf87195 h1:58f1tJ1ra+zFINPlwLWvQsR9CzAKt2e+EWV2yX9oXQ4= +github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY= +github.com/creack/pty v1.1.9 h1:uDmaGzcdjhF4i/plgjmEsriH11Y0o7RKapEf/LDaM3w= +github.com/envoyproxy/go-control-plane v0.11.0 h1:jtLewhRR2vMRNnq2ZZUoCjUlgut+Y0+sDDWPOfwOi1o= +github.com/envoyproxy/protoc-gen-validate v0.10.0 h1:oIfnZFdC0YhpNNEX+SuIqko4cqqVZeN9IGTrhZje83Y= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= +github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4= +github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= +github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= +github.com/golang/glog v1.1.0 h1:/d3pCKDPWNnvIWe0vVUpNP32qc8U3PDVxySP/y360qE= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= +github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= +github.com/kr/pty v1.1.1 h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw= +github.com/otiai10/curr v1.0.0 h1:TJIWdbX0B+kpNagQrjgq8bCMrbhiuX73M2XwgtDMoOI= +github.com/otiai10/mint v1.3.3 h1:7JgpsBaN0uMkyju4tbYHu0mnM55hNKVYLsXmwr15NQI= +github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= +github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= +github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= +github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M= +github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c h1:u40Z8hqBAAQyv+vATcGgV0YCnDjqSL7/q/JyPhhJSPk= +github.com/xdg/stringprep v1.0.0 h1:d9X0esnoa3dFsV0FG35rAT0RIhYFlPq7MiP+DW89La0= +github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/oauth2 v0.6.0 h1:Lh8GPgSKBfWSwFvtuWOfeI3aAAnbXTSutYxJiOJFgIw= +golang.org/x/term v0.7.0 h1:BEvjmm5fURWqcfbSKTdpkDXYBrUS1c0m8agp14W48vQ= golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= +rsc.io/pdf v0.1.1 h1:k1MczvYDUvJBe93bYd7wrZLLUEcLZAuF824/I4e5Xr4= diff --git a/shortener/build/consumer/Dockerfile b/shortener/build/consumer/Dockerfile new file mode 100644 index 0000000..6cd9912 --- /dev/null +++ b/shortener/build/consumer/Dockerfile @@ -0,0 +1,28 @@ +FROM golang:1.20.3 AS builder +LABEL maintainer="taufikjanuar35@gmail.com" + +RUN go version + +WORKDIR /shortener +COPY ./shortener/go.mod ./ +COPY ./shortener/go.sum ./ + +RUN go mod download + +COPY ./shortener . + +# Build Go App +RUN CGO_ENABLED=0 GOOS=linux go build -o shortener-service ./cmd/v1 + +FROM alpine:3.11.3 + +WORKDIR /app + +RUN mkdir cmd docs + +COPY --from=builder ./shortener/cmd/ ./cmd +COPY --from=builder ./shortener/docs/ ./docs +COPY --from=builder ./shortener/shortener-service . + +# Command to run the executeable +ENTRYPOINT ["./shortener-service","consumer"] diff --git a/shortener/build/grpc/Dockerfile b/shortener/build/grpc/Dockerfile new file mode 100644 index 0000000..b92ae3c --- /dev/null +++ b/shortener/build/grpc/Dockerfile @@ -0,0 +1,31 @@ +FROM golang:1.20.3 AS builder +LABEL maintainer="taufikjanuar35@gmail.com" + +RUN go version + +WORKDIR /shortener +COPY ./shortener/go.mod ./ +COPY ./shortener/go.sum ./ + +RUN go mod download + +COPY ./shortener . + +# Build Go App +RUN CGO_ENABLED=0 GOOS=linux go build -o shortener-service ./cmd/v1 + +FROM alpine:3.11.3 + +WORKDIR /app + +RUN mkdir cmd docs + +COPY --from=builder ./shortener/cmd/ ./cmd +COPY --from=builder ./shortener/docs/ ./docs +COPY --from=builder ./shortener/shortener-service . + +# Expose port +EXPOSE 9091 + +# Command to run the executeable +ENTRYPOINT ["./shortener-service","grpc"] diff --git a/shortener/build/http/Dockerfile b/shortener/build/http/Dockerfile new file mode 100644 index 0000000..0cae5c4 --- /dev/null +++ b/shortener/build/http/Dockerfile @@ -0,0 +1,31 @@ +FROM golang:1.20.3 AS builder +LABEL maintainer="taufikjanuar35@gmail.com" + +RUN go version + +WORKDIR /shortener +COPY ./shortener/go.mod ./ +COPY ./shortener/go.sum ./ + +RUN go mod download + +COPY ./shortener . + +# Build Go App +RUN CGO_ENABLED=0 GOOS=linux go build -o shortener-service ./cmd/v1 + +FROM alpine:3.11.3 + +WORKDIR /app + +RUN mkdir cmd docs + +COPY --from=builder ./shortener/cmd/ ./cmd +COPY --from=builder ./shortener/docs/ ./docs +COPY --from=builder ./shortener/shortener-service . + +# Expose port +EXPOSE 8081 + +# Command to run the executeable +ENTRYPOINT ["./shortener-service","http"] diff --git a/shortener/internal/v1/config/.env b/shortener/cmd/v1/.env similarity index 74% rename from shortener/internal/v1/config/.env rename to shortener/cmd/v1/.env index e088c2c..19c0a3e 100644 --- a/shortener/internal/v1/config/.env +++ b/shortener/cmd/v1/.env @@ -1,16 +1,16 @@ APP_PORT=8081 -DB_HOST=localhost +DB_HOST=mongo DB_PORT=27017 DB_NAME=singkatin DB_COLLECTION_USERS=users DB_COLLECTION_SHORTENERS=shorteners -REDIS_HOST=localhost +REDIS_HOST=redis REDIS_PORT=6379 REDIS_TTL=5 -AMQP_SERVER_URL=amqp://guest:guest@localhost:5672/ +AMQP_SERVER_URL=amqp://guest:guest@amqp:5672/ AMQP_QUEUE_CREATE_SHORTENER=create-shortener-queue AMQP_QUEUE_UPDATE_VISITOR_COUNT=update-visitor-count-queue diff --git a/shortener/cmd/v1/main.go b/shortener/cmd/v1/main.go index 365db9e..4636891 100644 --- a/shortener/cmd/v1/main.go +++ b/shortener/cmd/v1/main.go @@ -35,7 +35,10 @@ const ( // @BasePath /v1 // @Schemes http func main() { - _ = godotenv.Load("./shortener/internal/v1/config/.env") + err := godotenv.Load("./cmd/v1/.env") + if err != nil { + panic(err) + } runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/shortener/docs/docs.go b/shortener/docs/docs.go index d4bbae3..90bdc35 100644 --- a/shortener/docs/docs.go +++ b/shortener/docs/docs.go @@ -72,8 +72,8 @@ const docTemplate = `{ } ], "responses": { - "200": { - "description": "OK", + "301": { + "description": "Moved Permanently", "schema": { "$ref": "#/definitions/helper.BaseResponse" } diff --git a/shortener/docs/swagger.json b/shortener/docs/swagger.json index fa581cb..5f81169 100644 --- a/shortener/docs/swagger.json +++ b/shortener/docs/swagger.json @@ -68,8 +68,8 @@ } ], "responses": { - "200": { - "description": "OK", + "301": { + "description": "Moved Permanently", "schema": { "$ref": "#/definitions/helper.BaseResponse" } diff --git a/shortener/docs/swagger.yaml b/shortener/docs/swagger.yaml index aac7717..78ccbb1 100644 --- a/shortener/docs/swagger.yaml +++ b/shortener/docs/swagger.yaml @@ -42,8 +42,8 @@ paths: produces: - application/json responses: - "200": - description: OK + "301": + description: Moved Permanently schema: $ref: '#/definitions/helper.BaseResponse' "400": diff --git a/shortener/internal/v1/controller/short.go b/shortener/internal/v1/controller/short.go index 8db9ad4..f3fa60e 100644 --- a/shortener/internal/v1/controller/short.go +++ b/shortener/internal/v1/controller/short.go @@ -82,7 +82,7 @@ func (sc *ShortControllerImpl) GetListShortenerByUserID(ctx context.Context, req // @Accept json // @Produce json // @Param short_url path string true "short urls" -// @Success 200 {object} helper.BaseResponse +// @Success 301 {object} helper.BaseResponse // @Failure 400 {object} helper.BaseResponse // @Failure 404 {object} helper.BaseResponse // @Failure 500 {object} helper.BaseResponse diff --git a/shortener/internal/v1/repository/short.go b/shortener/internal/v1/repository/short.go index 5278592..fd115f2 100644 --- a/shortener/internal/v1/repository/short.go +++ b/shortener/internal/v1/repository/short.go @@ -119,7 +119,7 @@ func (sr *ShortRepositoryImpl) GetFullURLByKey(ctx context.Context, shortURL str return "", result.Err() } - return result.String(), nil + return result.Val(), nil } func (sr *ShortRepositoryImpl) SetFullURLByKey(ctx context.Context, shortURL string, fullURL string, duration time.Duration) error { diff --git a/shortener/internal/v1/service/short.go b/shortener/internal/v1/service/short.go index accf58f..de4dee9 100644 --- a/shortener/internal/v1/service/short.go +++ b/shortener/internal/v1/service/short.go @@ -96,6 +96,8 @@ func (ss *ShortServiceImpl) ClickShort(shortURL string) (*model.ClickShortRespon return &model.ClickShortResponse{FullURL: data.FullURL}, nil } + + return nil, err } ss.Logger.Info("get data from caching....") diff --git a/user/build/http/Dockerfile b/user/build/http/Dockerfile new file mode 100644 index 0000000..b0cd8b7 --- /dev/null +++ b/user/build/http/Dockerfile @@ -0,0 +1,31 @@ +FROM golang:1.20.3 AS builder +LABEL maintainer="taufikjanuar35@gmail.com" + +RUN go version + +WORKDIR /user +COPY ./user/go.mod ./ +COPY ./user/go.sum ./ + +RUN go mod download + +COPY ./user . + +# Build Go App +RUN CGO_ENABLED=0 GOOS=linux go build -o user-service ./cmd/v1 + +FROM alpine:3.11.3 + +WORKDIR /app + +RUN mkdir cmd docs + +COPY --from=builder ./user/cmd/ ./cmd +COPY --from=builder ./user/docs/ ./docs +COPY --from=builder ./user/user-service . + +# Expose port +EXPOSE 8082 + +# Command to run the executeable +ENTRYPOINT ["./user-service","http"] diff --git a/user/internal/v1/config/.env b/user/cmd/v1/.env similarity index 70% rename from user/internal/v1/config/.env rename to user/cmd/v1/.env index 7b9d30e..fbd37d4 100644 --- a/user/internal/v1/config/.env +++ b/user/cmd/v1/.env @@ -1,16 +1,16 @@ APP_PORT=8082 -DB_HOST=localhost +DB_HOST=mongo DB_PORT=27017 DB_NAME=singkatin DB_COLLECTION_USERS=users DB_COLLECTION_SHORTENERS=shorteners -AMQP_SERVER_URL=amqp://guest:guest@localhost:5672/ +AMQP_SERVER_URL=amqp://guest:guest@amqp:5672/ AMQP_QUEUE_CREATE_SHORTENER=create-shortener-queue AMQP_QUEUE_UPDATE_VISITOR_COUNT=update-visitor-count-queue JWT_SECRET=secret JWT_EXPIRE=7 -GRPC_SHORTENER_HOST=localhost:9091 \ No newline at end of file +GRPC_SHORTENER_HOST=shortener-service-grpc:9091 \ No newline at end of file diff --git a/user/cmd/v1/main.go b/user/cmd/v1/main.go index 8d66dac..4dd5e3e 100644 --- a/user/cmd/v1/main.go +++ b/user/cmd/v1/main.go @@ -27,7 +27,10 @@ const ( // @BasePath /v1 // @Schemes http func main() { - _ = godotenv.Load("./user/internal/v1/config/.env") + err := godotenv.Load("./cmd/v1/.env") + if err != nil { + panic(err) + } runtime.GOMAXPROCS(runtime.NumCPU())