Skip to content

Commit

Permalink
add: envoy binary file in backend image
Browse files Browse the repository at this point in the history
  • Loading branch information
minoic committed Jul 5, 2024
1 parent 25df818 commit 3064a28
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
6 changes: 4 additions & 2 deletions modules/backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ RUN --mount=type=cache,target=/go/pkg/mod \
go build -gcflags "all=-N -l" -ldflags "-s -w -X 'main.GoVersion=$(go version)' -X 'main.BuildTime=$(date "+%F %T")'" -o entry modules/$MODULE/main.go \
&& upx -6 entry

FROM envoyproxy/envoy:distroless-v1.30.4 AS envoy-alpine

FROM chromedp/headless-shell

EXPOSE $PORT
ENV TZ=Asia/Shanghai
COPY --from=envoy-alpine --chmod=755 /usr/local/bin/envoy /usr/local/bin
RUN DEBIAN_FRONTEND=noninteractive TZ=Asia/Shanghai apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends ca-certificates curl tzdata
&& apt-get -qq install -y --no-install-recommends ca-certificates curl tzdata
# RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories \
# && apk upgrade --no-cache --available \
# && apk --no-cache add tzdata ca-certificates libc6-compat libgcc libstdc++ curl
Expand Down
16 changes: 8 additions & 8 deletions modules/backend/app/mobile/grpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ package mobile

import (
"context"
"math"
"net"
"time"

"github.com/bellis-daemon/bellis/modules/backend/midwares"
"github.com/minoic/glgf"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/keepalive"
"math"
"net"
"time"
)

var (
server *grpc.Server
server *grpc.Server
)

func init() {
Expand Down Expand Up @@ -55,10 +56,9 @@ func ServeGrpc(ctx context.Context, lis net.Listener) {
panic(err)
}
}()
select {
case <-ctx.Done():
server.GracefulStop()
}
<-ctx.Done()
glgf.Info("Stopping GRPC server...")
server.GracefulStop()
}

func Server() *grpc.Server {
Expand Down
2 changes: 1 addition & 1 deletion modules/backend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func main() {
go web.ServeWeb(ctx, webL)
go m.Serve()
go RunHeadlessChrome()
quit := make(chan os.Signal)
quit := make(chan os.Signal, 1)
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
<-quit
glgf.Warn("Shutting down server")
Expand Down

0 comments on commit 3064a28

Please sign in to comment.