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 關注
- 361 瀏覽
添加回答
舉報