feat: api部分基本完成
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
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_{{ .Name }} ./app/api/{{ .Name }}
|
||||
|
||||
FROM reg.icechen.cn/alpine as {{ .Name }}
|
||||
WORKDIR /go/src
|
||||
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
|
||||
COPY --from=builder /go/src/api_{{ .Name }} ./
|
||||
ENV TZ=Asia/Shanghai
|
||||
RUN chmod +x ./api_{{ .Name }}
|
||||
EXPOSE 8080
|
||||
CMD ["./api_{{ .Name }}"]
|
||||
@@ -0,0 +1,17 @@
|
||||
package golang
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"github.com/fatih/color"
|
||||
|
||||
"git.icechen.cn/pkg/wdt/util"
|
||||
)
|
||||
|
||||
//go:embed "Dockerfile.tpl"
|
||||
var dockerfileTemplate string
|
||||
|
||||
func GenDockerfile(name string) error {
|
||||
color.Green("正在生成dockerfile...")
|
||||
return util.TemplateToFile("app/api/"+name+"/Dockerfile", dockerfileTemplate, map[string]string{"Name": name})
|
||||
}
|
||||
Reference in New Issue
Block a user