Tag: 静态文件

使用Docker容器部署Golang Web应用程序静态文件

我正在处理一个有一些静态文件(config和html模板)的小型web应用程序: ├── Dockerfile ├── manifest.json ├── session │ ├── config.go │ ├── handlers.go │ └── restapi_client.go ├── templates │ ├── header.tmpl │ └── index.tmpl └── webserver.go 例如,代码中的模板被发现与本地path(这是一个很好的做法? ): func init() { templates = template.Must(template.ParseGlob("templates/*.tmpl")) } Docker容器用于应用程序部署。 正如你可以在Dockerfile看到的,我必须复制/go/bin目录中的所有静态文件: FROM golang:latest ENV PORT=8000 ADD . /go/src/webserver/ RUN go install webserver RUN go get webserver # Copy static […]