Skip to content

Instantly share code, notes, and snippets.

@JoelPM
Created July 14, 2015 23:30
Show Gist options
  • Save JoelPM/1f65ed32e7032d9401cd to your computer and use it in GitHub Desktop.
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.
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"]
FROM busybox
MAINTAINER Joel Meyer <[email protected]>
ADD ./kubegateway /kubegateway
ADD ./kubegateway.go /kubegateway.go
ENTRYPOINT ["/kubegateway"]
.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