Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: reduce image size #511

Merged
merged 1 commit into from
Oct 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}