From d7c15d003bf8a8b0f412f4490d0698d9141062e9 Mon Sep 17 00:00:00 2001 From: icechen Date: Mon, 27 Dec 2021 21:02:11 +0800 Subject: [PATCH] update --- app/api/example_api/Dockerfile | 24 ++++++++++++++++++++++++ app/api/example_api/example_api.go | 13 ++++++++++++- go.mod | 10 ++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 app/api/example_api/Dockerfile diff --git a/app/api/example_api/Dockerfile b/app/api/example_api/Dockerfile new file mode 100644 index 0000000..d6e9d66 --- /dev/null +++ b/app/api/example_api/Dockerfile @@ -0,0 +1,24 @@ +FROM golang:1.17 as builder +ENV GO111MODULE on +ENV GOPROXY https://goproxy.io,direct +WORKDIR /go/cache +ADD go.mod . +ADD go.sum . +RUN go mod download +WORKDIR /go/src +ADD . . +RUN go mod tidy +RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o api_example_api + +FROM alpine as brahma-api +WORKDIR /go/src +#LABEL maintainer "The Prometheus Authors " +COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo +# copy main and config from builder +COPY --from=builder /go/src/api_example_api ./ +ENV TZ=Asia/Shanghai +ENV env=pro +ENV endpoints=http://etcd-server:2379 +RUN chmod +x ./main +EXPOSE 8080 +CMD ["./main"] \ No newline at end of file diff --git a/app/api/example_api/example_api.go b/app/api/example_api/example_api.go index 70cfa68..64db7bc 100644 --- a/app/api/example_api/example_api.go +++ b/app/api/example_api/example_api.go @@ -1,7 +1,18 @@ package main -import "git.icechen.cn/pkg/go-template/app/service/example_service/pkg/user" +import ( + "git.icechen.cn/pkg/go-template/app/service/example_service/pkg/user" + "github.com/gofiber/fiber/v2" +) func main() { user.GetUser() + app := fiber.New() + app.Get("/test", func(c *fiber.Ctx) error { + return c.SendString("success") + }) + err := app.Listen(":8080") + if err != nil { + panic(err) + } } diff --git a/go.mod b/go.mod index 0b3801c..93489c9 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,13 @@ module git.icechen.cn/pkg/go-template go 1.17 + +require ( + github.com/andybalholm/brotli v1.0.4 // indirect + github.com/gofiber/fiber/v2 v2.23.0 // indirect + github.com/klauspost/compress v1.13.6 // indirect + github.com/valyala/bytebufferpool v1.0.0 // indirect + github.com/valyala/fasthttp v1.31.0 // indirect + github.com/valyala/tcplisten v1.0.0 // indirect + golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect +)