Created
July 14, 2015 23:30
-
-
Save JoelPM/1f65ed32e7032d9401cd to your computer and use it in GitHub Desktop.
Building golang using a dev container with godep. Got things to build, but the binary wouldn't run when executing under busybox.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM golang:1.4.2-cross | |
RUN go get github.com/tools/godep | |
RUN CGO_ENABLED=0 go install -a std | |
MAINTAINER Joel Meyer <[email protected]> | |
WORKDIR /go/src/github.com/joelpm/kubegateway | |
COPY go-package-setup /usr/local/bin/ | |
ENTRYPOINT ["/bin/sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM busybox | |
MAINTAINER Joel Meyer <[email protected]> | |
ADD ./kubegateway /kubegateway | |
ADD ./kubegateway.go /kubegateway.go | |
ENTRYPOINT ["/kubegateway"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.PHONY: all kubegateway container push clean test | |
APP = kubegateway | |
TAG = 0.0.2 | |
PREFIX = joelpm | |
DEVCONTAINER = $(PREFIX)/$(APP)_dev:1.4.2 | |
all: container | |
.devcontainer: | |
docker build -t $(DEVCONTAINER) ./dev/ | |
docker inspect -f '{{.Id}}' $(DEVCONTAINER) > dev/.devcontainer | |
devcontainer: .devcontainer | |
cmd: | |
docker run -v $(PWD):/go/src/github.com/joelpm/kubegateway $(DEVCONTAINER) | |
binary: devcontainer | |
docker run -v $(PWD):/go/src/github.com/joelpm/kubegateway $(DEVCONTAINER) -c 'make $(APP)' | |
godep: devcontainer | |
docker run -v $(PWD):/go/src/github.com/joelpm/kubegateway $(DEVCONTAINER) -c 'go get && godep save' | |
$(APP): $(APP).go | |
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 godep go build -a --ldflags '-w' -o $(APP) ./$(APP).go | |
container: binary | |
docker build -t $(PREFIX)/$(APP):$(TAG) . | |
push: | |
gcloud docker push $(PREFIX)/$(APP):$(TAG) | |
clean: | |
rm -f $(APP) | |
test: clean | |
godep go test -v --vmodule=*=4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment