Skip to content
Browse files

compiles statically linked spread and puts it into the gitlab image

  • Loading branch information...
1 parent 5918c21 commit cbb57654948810c5476a2ddcebf648d517daf9bb @ethernetdan ethernetdan committed
Showing with 29 additions and 3 deletions.
  1. +2 −0 .gitignore
  2. +24 −1 Makefile
  3. +3 −2 images/gitlabci/Dockerfile
View
2 .gitignore
@@ -23,3 +23,5 @@ _testmain.go
*.exe
*.test
*.prof
+
+build/
View
25 Makefile
@@ -11,14 +11,26 @@ GO ?= go
GOX ?= gox
GOFMT ?= gofmt # eventually should add "-s"
GOLINT ?= golint
+DOCKER ?= docker
GOFILES := find . -name '*.go' -not -path "./vendor/*"
GOBUILD_LDFLAGS ?=
-GOBUILD_FLAGS ?=
+GOBUILD_FLAGS ?= -i -v
GOTEST_FLAGS ?= -v
GOX_FLAGS ?= -output="build/{{.Dir}}_{{.OS}}_{{.Arch}}" -os="${GOX_OS}" -arch="${GOX_ARCH}"
+STATIC_LDFLAGS ?= --ldflags '-extldflags "-static" --s -w'
+
+GITLAB_CONTEXT ?= ./build/gitlab
+
+# image data
+ORG ?= redspreadapps
+NAME ?= spread-gitlab
+TAG ?= latest
+
+GITLAB_IMAGE_NAME = "$(ORG)/$(NAME):$(TAG)"
+
GOX_OS ?= linux darwin windows
GOX_ARCH ?= amd64
@@ -39,10 +51,21 @@ validate: lint checkgofmt vet
build:
$(GO) install $(GOBUILD_FLAGS) $(GOBUILD_LDFLAGS) $(EXEC_PKG)
+build/spread-linux-static:
+ GOOS=linux $(GO) build -o $@ $(GOBUILD_FLAGS) $(STATIC_LDFLAGS) $(EXEC_PKG)
+ chmod +x $@
+
.PHONY: crossbuild
crossbuild: deps gox-setup
$(GOX) $(GOX_FLAGS) -gcflags="$(GOBUILD_FLAGS)" -ldflags="$(GOBUILD_LDFLAGS)" $(EXEC_PKG)
+.PHONY: build-gitlab
+build-gitlab: build/spread-linux-static
+ rm -rf $(GITLAB_CONTEXT)
+ cp -r ./images/gitlabci $(GITLAB_CONTEXT)
+ cp ./build/spread-linux-static $(GITLAB_CONTEXT)
+ $(DOCKER) build $(DOCKER_OPTS) -t $(GITLAB_IMAGE_NAME) $(GITLAB_CONTEXT)
+
.PHONY: vet
vet:
$(GO) vet $(PKGS)
View
5 images/gitlabci/Dockerfile
@@ -4,9 +4,10 @@ RUN apk-install bash
WORKDIR /opt/spread-gitlab
-ADD spread-linux /usr/local/bin/spread
+ADD spread-linux-static /usr/local/bin/spread
ADD entrypoint.sh ./entrypoint.sh
ENV KUBECFG_INSECURE_SKIP_TLS_VERIFY="false"
+ENV DEPLOY_DIR="."
-ENTRYPOINT ["entrypoint.sh"]
+ENTRYPOINT ["./entrypoint.sh"]

0 comments on commit cbb5765

Please sign in to comment.
Something went wrong with that request. Please try again.