Skip to content

Commit

Permalink
Merge 0ced699 into 2328fb3
Browse files Browse the repository at this point in the history
  • Loading branch information
asauber committed Jun 25, 2019
2 parents 2328fb3 + 0ced699 commit 3d42cb1
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 23 deletions.
16 changes: 3 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
# Build the manager binary
FROM golang:1.12.4 as builder

WORKDIR /go/src/github.com/linode/linode-cloud-controller-manager
COPY go.* *.go ./
COPY cloud/ ./cloud
ENV GO111MODULE=on

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o linode-cloud-controller-manager github.com/linode/linode-cloud-controller-manager

# NB: We now cross-compile the go binary locally using the Makefile
FROM alpine:latest
RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*
WORKDIR /root/
COPY --from=builder /go/src/github.com/linode/linode-cloud-controller-manager/linode-cloud-controller-manager /
ENTRYPOINT ["/linode-cloud-controller-manager"]
COPY dist/ccm-linode-linux-amd64 /
ENTRYPOINT ["/ccm-linode-linux-amd64"]
55 changes: 46 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,39 +1,78 @@
IMG ?= linode/linode-cloud-controller-manager:latest
IMG ?= linode/linode-cloud-controller-manager:canary

export GO111MODULE=on

.PHONY: all
all: build

.PHONY: clean
clean:
go clean .
rm -r dist/*

$(GOPATH)/bin/goimports:
GO111MODULE=off go get golang.org/x/tools/cmd/goimports

$(GOPATH)/bin/ginkgo:
GO111MODULE=off go get -u github.com/onsi/ginkgo/ginkgo

.PHONY: vet
# lint the codebase
vet:
go vet -composites=false ./...
go vet . ./cloud/...

.PHONY: fmt
# goimports runs a go fmt
# we say code is not worth formatting unless it's linted
fmt: vet $(GOPATH)/bin/goimports
# goimports runs a gofmt
goimports -w *.go cloud

test: $(GOPATH)/bin/ginkgo
.PHONY: test
# we say code is not worth testing unless it's formatted
test: $(GOPATH)/bin/ginkgo fmt
ginkgo -r --v --progress --trace --cover --skipPackage=test -- --v=3

build: test fmt
go build -o dist/linode-cloud-controller-manager github.com/linode/linode-cloud-controller-manager
.PHONY: build-linux
build-linux:
echo "cross compiling ccm-linode for linux/amd64" && \
GOOS=linux GOARCH=amd64 \
CGO_ENABLED=0 \
go build -o dist/ccm-linode-linux-amd64 .

.PHONY: build
build:
echo "compiling ccm-linode" && \
CGO_ENABLED=0 \
go build -o dist/ccm-linode .

docker-build: build
.PHONY: imgname
# print the Docker image name that will be used
# useful for subsequently defining it on the shell
imgname:
echo IMG=${IMG}

.PHONY: docker-build
# we cross compile the binary for linux, then build a container
docker-build: build-linux
docker build . -t ${IMG}

.PHONY: docker-push
# must run the docker build before pushing the image
docker-push:
echo "[reminder] Did you run `make docker-build`?"
docker push ${IMG}

.PHONY: run
# run the ccm locally, really only makes sense on linux anyway
run: build
dist/linode-cloud-controller-manager \
--logtostderr=true \
--stderrthreshold=INFO \
--cloud-provider=linode \
--kubeconfig=${KUBECONFIG}

.PHONY: run-debug
# run the ccm locally, really only makes sense on linux anyway
run-debug: build
dist/linode-cloud-controller-manager \
--logtostderr=true \
Expand All @@ -42,5 +81,3 @@ run-debug: build
--kubeconfig=${KUBECONFIG} \
--linodego-debug

all: build

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ require (
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jonboulle/clockwork v0.1.0 // indirect
github.com/json-iterator/go v1.1.6 // indirect
github.com/linode/linodego v0.9.0
github.com/linode/linodego v0.10.0
github.com/mailru/easyjson v0.0.0-20170624190925-2f5df55504eb // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/linode/linodego v0.9.0 h1:FnWYh6myo4yuiRmui0rpU0TsCVwLbgX1L7/ibmFYenE=
github.com/linode/linodego v0.9.0/go.mod h1:cziNP7pbvE3mXIPneHj0oRY8L1WtGEIKlZ8LANE4eXA=
github.com/linode/linodego v0.10.0 h1:AMdb82HVgY8o3mjBXJcUv9B+fnJjfDMn2rNRGbX+jvM=
github.com/linode/linodego v0.10.0/go.mod h1:cziNP7pbvE3mXIPneHj0oRY8L1WtGEIKlZ8LANE4eXA=
github.com/mailru/easyjson v0.0.0-20170624190925-2f5df55504eb h1:D5TlrOFWiDz5VIdPnkPwyIRIgStzH3wBBS7v1O1cfSY=
github.com/mailru/easyjson v0.0.0-20170624190925-2f5df55504eb/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (
)

func main() {
fmt.Printf("Linode Cloud Controller Manager starting up\n")

rand.Seed(time.Now().UTC().UnixNano())

command := app.NewCloudControllerManagerCommand()
Expand Down

0 comments on commit 3d42cb1

Please sign in to comment.