3 回答

TA贡献1825条经验 获得超4个赞
有几种策略:
使用预构建应用程序。
go build
根据目标系统架构和操作系统(例如使用 GOOS 和 GOARCH 系统变量)使用命令构建您的应用程序,然后使用 COPY docker 命令将此构建的文件(带有资产和模板)移动到您的 WORKDIR,最后通过 CMD 或 ENTRYPOINT 运行它( 最后一个是可取的)。此示例的 Dockerfile 如下所示:
从头开始
环境端口 8000 暴露 $PORT
COPY 降临 / CMD ["/降临"]
通过 dockerfile 构建。典型的 Dockerfile:
# Start from a Debian image with the latest version of Go installed
# and a workspace (GOPATH) configured at /go.
FROM golang
# Copy the local package files to the container's workspace.
ADD . /go/src/github.com/golang/example/outyet
# Build the outyet command inside the container.
# (You may fetch or manage dependencies here,
# either manually or with a tool like "godep".)
RUN go install github.com/golang/example/outyet
# Run the outyet command by default when the container starts.
ENTRYPOINT /go/bin/outyet
# Document that the service listens on port 8080.
EXPOSE 8080
使用 GitHub。构建您的应用程序并将其拉到 dockerhub 作为准备使用的图像。

TA贡献2016条经验 获得超9个赞
Github 支持Webhooks,当你推送到 git repo 时,它可以用来自动做各种事情。既然你已经在你的家庭机器上运行了一个网络服务器,为什么你不让 Github 在它收到提交时向它发送一个 POST 请求并让master
你的家庭机器重新下载 git repo 并从那里重新启动网络服务?

TA贡献1805条经验 获得超10个赞
我能够通过通过 docker hub 创建自动构建并将其用于我的 dockerfile 来解决我的问题:
FROM golang-onbuild EXPOSE <ports>
这不是我的问题的正确答案,但它是一种有效的解决方法。自动构建以我希望我的 dockerfile 的方式与我的 github 存储库连接。
- 3 回答
- 0 关注
- 320 浏览
添加回答
举报