Skip to content

Commit

Permalink
build: docker dev image on each main branch commit (#224)
Browse files Browse the repository at this point in the history
Signed-off-by: Kush Sharma <[email protected]>
  • Loading branch information
kushsharma authored Sep 3, 2023
1 parent 5f9096d commit dea4e8a
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 3 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Main
on:
push:
branches:
- main

jobs:
dev:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
- name: Login to DockerHub
uses: docker/login-action@v1
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Publish dev image
id: docker_dev_build
uses: docker/build-push-action@v2
with:
push: true
file: "./Dockerfile.dev"
tags: raystack/compass:dev
17 changes: 17 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM golang:1.20-alpine3.17 as builder
RUN apk add make
WORKDIR /build/
COPY . .
RUN make build

FROM alpine:3.17

COPY --from=builder /build/compass /usr/bin/compass
RUN apk update
RUN apk add ca-certificates

# glibc compatibility library, since go binaries
# don't work well with musl libc that alpine uses
RUN apk add libc6-compat

ENTRYPOINT ["compass"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ coverage: test ## Print the code coverage

build: ## Build the compass binary
@echo "Building guardian version ${VERSION}..."
go build -ldflags "-X ${NAME}/cli.Version=${VERSION}"
CGO_ENABLED=0 go build -ldflags "-X ${NAME}/cli.Version=${VERSION}"
@echo "Build complete"

buildr: setup
Expand Down
6 changes: 4 additions & 2 deletions internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ func Serve(

// init grpc
grpcServer := grpc.NewServer(
grpc.MaxRecvMsgSize(config.GRPC.MaxRecvMsgSize),
grpc.MaxSendMsgSize(config.GRPC.MaxSendMsgSize),
grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer(
grpc_recovery.UnaryServerInterceptor(),
grpc_ctxtags.UnaryServerInterceptor(),
Expand Down Expand Up @@ -160,8 +162,8 @@ func Serve(
ctx,
mux.WithHTTPTarget(config.addr(), &http.Server{
Handler: gwmux,
ReadTimeout: 5 * time.Second,
WriteTimeout: 10 * time.Second,
ReadTimeout: 60 * time.Second,
WriteTimeout: 60 * time.Second,
IdleTimeout: 120 * time.Second,
}),
mux.WithGRPCTarget(config.grpcAddr(), grpcServer),
Expand Down

0 comments on commit dea4e8a

Please sign in to comment.