Skip to content

Commit

Permalink
finish up docker and http gateway generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Pritesh-Patel committed Oct 8, 2019
1 parent b09452c commit 3cecd83
Show file tree
Hide file tree
Showing 22 changed files with 228 additions and 514 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Expand Up @@ -58,6 +58,6 @@ COPY --from=builder /usr/local/bin /usr/local/bin
COPY --from=builder /usr/local/include /usr/local/include
COPY --from=builder /go/src/github.com/grpc-ecosystem/grpc-gateway ${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway
WORKDIR /project
RUN apk add --update --no-cache make bash curl git protobuf=${PROTOBUF_VERSION}-${ALPINE_PROTOBUF_VERSION_SUFFIX} && \
RUN apk add --update --no-cache make protobuf=${PROTOBUF_VERSION}-${ALPINE_PROTOBUF_VERSION_SUFFIX} && \
rm -rf /var/cache/apk/*
ENTRYPOINT ["sprout"]
10 changes: 10 additions & 0 deletions cmd/generate.go
Expand Up @@ -4,6 +4,10 @@ import (
"github.com/commitdev/sprout/config"
"github.com/commitdev/sprout/generate/golang"
"github.com/commitdev/sprout/generate/proto"
"github.com/commitdev/sprout/generate/docker"
"github.com/commitdev/sprout/generate/http"


"log"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -42,7 +46,13 @@ var generateCmd = &cobra.Command{
switch language {
case Go:
golang.Generate(Templator, cfg)
docker.GenerateGoAppDockerFile(Templator, cfg)

}

if cfg.Network.Http.Enabled {
http.GenerateHttpGW(Templator, cfg)
docker.GenerateGoHttpGWDockerFile(Templator, cfg)
}
},
}
Expand Down
Empty file.
11 changes: 11 additions & 0 deletions example/hello-world/docker/app/Dockerfile
@@ -0,0 +1,11 @@
FROM golang:1.12.6@sha256:83e8267be041b3ddf6a5792c7e464528408f75c446745642db08cfe4e8d58d18 AS build
WORKDIR /cache
COPY go.mod .
COPY . .
RUN go build -o hello-world

FROM alpine
RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2
RUN apk update && apk add ca-certificates
COPY --from=build /cache/hello-world /app/
ENTRYPOINT /app/hello-world
10 changes: 10 additions & 0 deletions example/hello-world/docker/http/Dockerfile
@@ -0,0 +1,10 @@
FROM golang:1.12.6@sha256:83e8267be041b3ddf6a5792c7e464528408f75c446745642db08cfe4e8d58d18 AS build
WORKDIR /cache
COPY . .
RUN go build http/main.go -o hello-world-http

FROM alpine
RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2
RUN apk update && apk add ca-certificates
COPY --from=build /cache/hello-world /app/
ENTRYPOINT /app/hello-world-http
4 changes: 2 additions & 2 deletions example/hello-world/hello-world-idl/Makefile
Expand Up @@ -42,9 +42,9 @@ generate-web:
cp -f -rv proto/Proto/* gen/web
rm -rf proto/proto proto/Proto
generate-http:
mkdir -p gen/http
mkdir -p gen/go
protoc ${PROTO_SOURCES} --grpc-gateway_out=logtostderr=true,paths=source_relative:proto --swagger_out=logtostderr=true:proto ./proto/health/*.proto
protoc ${PROTO_SOURCES} --grpc-gateway_out=logtostderr=true,paths=source_relative:proto --swagger_out=logtostderr=true:proto ./proto/helloworld/*.proto
cp -f -rv proto/proto/* gen/http
cp -f -rv proto/proto/* gen/go
rm -rf proto/proto

162 changes: 0 additions & 162 deletions example/hello-world/hello-world-idl/gen/http/health/health.pb.gw.go

This file was deleted.

This file was deleted.

0 comments on commit 3cecd83

Please sign in to comment.