Skip to content

Commit

Permalink
chore: reduce image size
Browse files Browse the repository at this point in the history
  • Loading branch information
oilbeater committed Oct 20, 2020
1 parent ad7fd71 commit 0da634e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
8 changes: 2 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ REGISTRY=kubeovn
DEV_TAG=dev
RELEASE_TAG=$(shell cat VERSION)
COMMIT=git-$(shell git rev-parse HEAD)
GOLDFLAGS="-w -s -X github.com/alauda/kube-ovn/versions.COMMIT=${COMMIT} -X github.com/alauda/kube-ovn/versions.VERSION=${RELEASE_TAG}"
DATA=$(shell date)
GOLDFLAGS="-w -s -X github.com/alauda/kube-ovn/versions.COMMIT=${COMMIT} -X github.com/alauda/kube-ovn/versions.VERSION=${RELEASE_TAG} -X github.com/alauda/kube-ovn/versions.BUILDDATE=${DATE}"

# ARCH could be amd64,arm64
ARCH=amd64
Expand All @@ -28,17 +29,13 @@ build-go:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $(PWD)/dist/images/kube-ovn-controller -ldflags $(GOLDFLAGS) -v ./cmd/controller
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $(PWD)/dist/images/kube-ovn-daemon -ldflags $(GOLDFLAGS) -v ./cmd/daemon
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $(PWD)/dist/images/kube-ovn-pinger -ldflags $(GOLDFLAGS) -v ./cmd/pinger
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $(PWD)/dist/images/kube-ovn-webhook -ldflags $(GOLDFLAGS) -v ./cmd/webhook
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $(PWD)/dist/images/kube-ovn-speaker -ldflags $(GOLDFLAGS) -v ./cmd/speaker
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $(PWD)/dist/images/kube-ovn-monitor -ldflags $(GOLDFLAGS) -v ./cmd/ovn_monitor

build-go-arm:
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o $(PWD)/dist/images/kube-ovn -ldflags $(GOLDFLAGS) -v ./cmd/cni
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o $(PWD)/dist/images/kube-ovn-controller -ldflags $(GOLDFLAGS) -v ./cmd/controller
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o $(PWD)/dist/images/kube-ovn-daemon -ldflags $(GOLDFLAGS) -v ./cmd/daemon
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o $(PWD)/dist/images/kube-ovn-pinger -ldflags $(GOLDFLAGS) -v ./cmd/pinger
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o $(PWD)/dist/images/kube-ovn-webhook -ldflags $(GOLDFLAGS) -v ./cmd/webhook
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o $(PWD)/dist/images/kube-ovn-speaker -ldflags $(GOLDFLAGS) -v ./cmd/speaker
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o $(PWD)/dist/images/kube-ovn-monitor -ldflags $(GOLDFLAGS) -v ./cmd/ovn_monitor

release: lint build-go
Expand All @@ -60,7 +57,6 @@ lint:
@GOOS=linux gosec -exclude=G204 ./...

build-bin:

docker run --rm -e GOOS=linux -e GOCACHE=/tmp -e GOARCH=${ARCH} -e GOPROXY=https://goproxy.cn \
-u $(shell id -u):$(shell id -g) \
-v $(CURDIR):/go/src/github.com/alauda/kube-ovn:ro \
Expand Down
5 changes: 1 addition & 4 deletions dist/images/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ RUN bash /root/build.sh && \

FROM centos:8
ENV BUILD_DATE 20200930
RUN sed -i s/\$releasever/8-stream/g /etc/yum.repos.d/CentOS-Base.repo && \
sed -i s/\$releasever/8-stream/g /etc/yum.repos.d/CentOS-AppStream.repo
RUN yum remove -y bind-export-libs && yum update -y && \
yum install -y \
firewalld-filesystem \
firewalld-filesystem openssl \
libatomic \
libpcap \
hostname ethtool \
Expand Down Expand Up @@ -57,7 +55,6 @@ COPY 01-kube-ovn.conflist /kube-ovn/01-kube-ovn.conflist

WORKDIR /kube-ovn

COPY kube-ovn-speaker /kube-ovn/kube-ovn-speaker
COPY kube-ovn-pinger /kube-ovn/kube-ovn-pinger
COPY kube-ovn /kube-ovn/kube-ovn
COPY kube-ovn-daemon /kube-ovn/kube-ovn-daemon
Expand Down
8 changes: 4 additions & 4 deletions versions/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package versions
import (
"fmt"
"runtime"
"time"
)

var (
COMMIT = "unknown"
VERSION = "unknown"
COMMIT = "unknown"
VERSION = "unknown"
BUILDDATE = "unknown"
)

func String() string {
Expand All @@ -21,5 +21,5 @@ Kube-OVN:
Go Version: %v
Arch: %v
-------------------------------------------------------------------------------
`, VERSION, time.Now().String(), COMMIT, runtime.Version(), runtime.GOARCH)
`, VERSION, BUILDDATE, COMMIT, runtime.Version(), runtime.GOARCH)
}

0 comments on commit 0da634e

Please sign in to comment.