-
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.
Merge branch 'develop' of github.com:go-park-mail-ru/2023_2_Hamster i…
…nto deploy
- Loading branch information
Showing
64 changed files
with
5,412 additions
and
1,014 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
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 @@ | ||
# TODO: When initdb.sql updates rebuid docker on deploy action |
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,19 @@ | ||
#Builder | ||
FROM golang:1.21.0-alpine AS builder | ||
|
||
COPY . /github.com/go-park-mail-ru/2023_2_Hamster/ | ||
WORKDIR /github.com/go-park-mail-ru/2023_2_Hamster/ | ||
|
||
RUN go mod download | ||
RUN go clean --modcache | ||
RUN CGO_ENABLED=0 GOOS=linux go build -mod=readonly -o account ./cmd/account/account.go | ||
|
||
FROM scratch AS run | ||
|
||
WORKDIR /docker-hammywallet/ | ||
|
||
COPY --from=builder /github.com/go-park-mail-ru/2023_2_Hamster/account . | ||
|
||
EXPOSE 8020 | ||
|
||
ENTRYPOINT ["./account"] |
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,19 @@ | ||
#Builder | ||
FROM golang:1.21.0-alpine AS builder | ||
|
||
COPY . /github.com/go-park-mail-ru/2023_2_Hamster/ | ||
WORKDIR /github.com/go-park-mail-ru/2023_2_Hamster/ | ||
|
||
RUN go mod download | ||
RUN go clean --modcache | ||
RUN CGO_ENABLED=0 GOOS=linux go build -mod=readonly -o auth ./cmd/auth/main.go | ||
|
||
FROM scratch AS run | ||
|
||
WORKDIR /docker-hammywallet/ | ||
|
||
COPY --from=builder /github.com/go-park-mail-ru/2023_2_Hamster/auth . | ||
|
||
EXPOSE 8010 | ||
|
||
ENTRYPOINT ["./auth"] |
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,19 @@ | ||
#Builder | ||
FROM golang:1.21.0-alpine AS builder | ||
|
||
COPY . /github.com/go-park-mail-ru/2023_2_Hamster/ | ||
WORKDIR /github.com/go-park-mail-ru/2023_2_Hamster/ | ||
|
||
RUN go mod download | ||
RUN go clean --modcache | ||
RUN CGO_ENABLED=0 GOOS=linux go build -mod=readonly -o category ./cmd/category/category.go | ||
|
||
FROM scratch AS run | ||
|
||
WORKDIR /docker-hammywallet/ | ||
|
||
COPY --from=builder /github.com/go-park-mail-ru/2023_2_Hamster/category . | ||
|
||
EXPOSE 8030 | ||
|
||
ENTRYPOINT ["./category"] |
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,79 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"net" | ||
"net/http" | ||
"os" | ||
"time" | ||
|
||
"github.com/go-park-mail-ru/2023_2_Hamster/cmd/api/init/db/postgresql" | ||
"github.com/go-park-mail-ru/2023_2_Hamster/internal/common/logger" | ||
accountHandler "github.com/go-park-mail-ru/2023_2_Hamster/internal/microservices/account/delivery/grpc" | ||
generatedAccount "github.com/go-park-mail-ru/2023_2_Hamster/internal/microservices/account/delivery/grpc/generated" | ||
accountRep "github.com/go-park-mail-ru/2023_2_Hamster/internal/microservices/account/repository/postgresql" | ||
accountUsecase "github.com/go-park-mail-ru/2023_2_Hamster/internal/microservices/account/usecase" | ||
"github.com/go-park-mail-ru/2023_2_Hamster/internal/middleware" | ||
"github.com/gorilla/mux" | ||
"github.com/prometheus/client_golang/prometheus/promhttp" | ||
"google.golang.org/grpc" | ||
) | ||
|
||
func main() { | ||
if err := run(); err != nil { | ||
os.Exit(1) | ||
} | ||
} | ||
|
||
func run() (err error) { | ||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) | ||
defer cancel() | ||
log := logger.NewLogger(ctx) | ||
db, err := postgresql.InitPostgresDB(ctx) | ||
if err != nil { | ||
log.Errorf("Error Initializing PostgreSQL database: %v", err) | ||
return | ||
} | ||
defer func() { | ||
db.Close() | ||
|
||
log.Info("Db closed without errors") | ||
}() | ||
|
||
log.Info("Db connection successfully") | ||
|
||
accountRepo := accountRep.NewRepository(db, *log) | ||
|
||
accountUsecase := accountUsecase.NewUsecase(accountRepo, *log) | ||
|
||
service := accountHandler.NewAccountGRPC(accountUsecase, *log) | ||
|
||
srv, ok := net.Listen("tcp", ":8020") | ||
if ok != nil { | ||
log.Fatalln("can't listen port", err) | ||
} | ||
|
||
metricsMw := middleware.NewMetricsMiddleware() | ||
metricsMw.Register(middleware.ServiceAccountName) | ||
|
||
server := grpc.NewServer(grpc.UnaryInterceptor(metricsMw.ServerMetricsInterceptor)) | ||
|
||
generatedAccount.RegisterAccountServiceServer(server, service) | ||
r := mux.NewRouter().PathPrefix("/api").Subrouter() | ||
r.PathPrefix("/metrics").Handler(promhttp.Handler()) | ||
|
||
http.Handle("/", r) | ||
httpSrv := http.Server{Handler: r, Addr: ":8021"} | ||
|
||
go func() { | ||
err := httpSrv.ListenAndServe() | ||
if err != nil { | ||
fmt.Print(err) | ||
} | ||
}() | ||
|
||
fmt.Print("creator running on: ", srv.Addr()) | ||
return server.Serve(srv) | ||
|
||
} |
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
Oops, something went wrong.