master
icechen 2021-12-27 21:02:11 +08:00
parent 60487a0aab
commit d7c15d003b
3 changed files with 46 additions and 1 deletions

View File

@ -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 <prometheus-developers@googlegroups.com>"
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"]

View File

@ -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)
}
}

10
go.mod
View File

@ -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
)