Skip to content

Commit

Permalink
chore: fix image build
Browse files Browse the repository at this point in the history
  • Loading branch information
andyzhangx committed Apr 30, 2022
1 parent 24b4afa commit 2e8e6b4
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
26 changes: 13 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

CMDS=smb-csi
CMDS=smbplugin
PKG = github.com/kubernetes-csi/csi-driver-smb
GINKGO_FLAGS = -ginkgo.v
GO111MODULE = on
GOPATH ?= $(shell go env GOPATH)
GOBIN ?= $(GOPATH)/bin
DOCKER_CLI_EXPERIMENTAL = enabled
IMAGE_NAME ?= smb-csi
IMAGENAME ?= smb-csi
export GOPATH GOBIN GO111MODULE DOCKER_CLI_EXPERIMENTAL

include release-tools/build.make
Expand All @@ -35,11 +35,11 @@ ifndef PUBLISH
override IMAGE_VERSION := e2e-$(GIT_COMMIT)
endif
endif
IMAGE_TAG = $(REGISTRY)/$(IMAGE_NAME):$(IMAGE_VERSION)
IMAGE_TAG_LATEST = $(REGISTRY)/$(IMAGE_NAME):latest
IMAGE_TAG = $(REGISTRY)/$(IMAGENAME):$(IMAGE_VERSION)
IMAGE_TAG_LATEST = $(REGISTRY)/$(IMAGENAME):latest
BUILD_DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS ?= "-X ${PKG}/pkg/smb.driverVersion=${IMAGE_VERSION} -X ${PKG}/pkg/smb.gitCommit=${GIT_COMMIT} -X ${PKG}/pkg/smb.buildDate=${BUILD_DATE} -s -w -extldflags '-static'"
E2E_HELM_OPTIONS ?= --set image.smb.repository=$(REGISTRY)/$(IMAGE_NAME) --set image.smb.tag=$(IMAGE_VERSION) --set controller.dnsPolicy=ClusterFirstWithHostNet --set linux.dnsPolicy=ClusterFirstWithHostNet
E2E_HELM_OPTIONS ?= --set image.smb.repository=$(REGISTRY)/$(IMAGENAME) --set image.smb.tag=$(IMAGE_VERSION) --set controller.dnsPolicy=ClusterFirstWithHostNet --set linux.dnsPolicy=ClusterFirstWithHostNet
E2E_HELM_OPTIONS += ${EXTRA_HELM_OPTIONS}
# Generate all combination of all OS, ARCH, and OSVERSIONS for iteration
ALL_OS = linux windows
Expand Down Expand Up @@ -121,39 +121,39 @@ e2e-teardown:

.PHONY: smb
smb:
CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH) go build -a -ldflags "${LDFLAGS}" -mod vendor -o _output/${ARCH}/smbplugin ./pkg/smbplugin
CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH) go build -a -ldflags "${LDFLAGS}" -mod vendor -o _output/${ARCH}/smbplugin ./cmd/smbplugin

.PHONY: smb-armv7
smb-armv7:
CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -a -ldflags "${LDFLAGS}" -mod vendor -o _output/arm/v7/smbplugin ./pkg/smbplugin
CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -a -ldflags "${LDFLAGS}" -mod vendor -o _output/arm/v7/smbplugin ./cmd/smbplugin

.PHONY: smb-windows
smb-windows:
CGO_ENABLED=0 GOOS=windows go build -a -ldflags "${LDFLAGS}" -mod vendor -o _output/${ARCH}/smbplugin.exe ./pkg/smbplugin
CGO_ENABLED=0 GOOS=windows go build -a -ldflags "${LDFLAGS}" -mod vendor -o _output/${ARCH}/smbplugin.exe ./cmd/smbplugin

.PHONY: smb-darwin
smb-darwin:
CGO_ENABLED=0 GOOS=darwin go build -a -ldflags "${LDFLAGS}" -mod vendor -o _output/${ARCH}/smbplugin ./pkg/smbplugin
CGO_ENABLED=0 GOOS=darwin go build -a -ldflags "${LDFLAGS}" -mod vendor -o _output/${ARCH}/smbplugin ./cmd/smbplugin

.PHONY: container
container: smb
docker build --no-cache -t $(IMAGE_TAG) --output=type=docker -f ./pkg/smbplugin/Dockerfile .
docker build --no-cache -t $(IMAGE_TAG) --output=type=docker -f ./cmd/smbplugin/Dockerfile .

.PHONY: container-linux
container-linux:
docker buildx build --pull --output=type=$(OUTPUT_TYPE) --platform="linux/$(ARCH)" \
-t $(IMAGE_TAG)-linux-$(ARCH) --build-arg ARCH=$(ARCH) -f ./pkg/smbplugin/Dockerfile .
-t $(IMAGE_TAG)-linux-$(ARCH) --build-arg ARCH=$(ARCH) -f ./cmd/smbplugin/Dockerfile .

.PHONY: container-linux-armv7
container-linux-armv7:
docker buildx build --pull --output=type=$(OUTPUT_TYPE) --platform="linux/arm/v7" \
-t $(IMAGE_TAG)-linux-arm-v7 --build-arg ARCH=arm/v7 -f ./pkg/smbplugin/Dockerfile .
-t $(IMAGE_TAG)-linux-arm-v7 --build-arg ARCH=arm/v7 -f ./cmd/smbplugin/Dockerfile .

.PHONY: container-windows
container-windows:
docker buildx build --pull --output=type=$(OUTPUT_TYPE) --platform="windows/$(ARCH)" \
-t $(IMAGE_TAG)-windows-$(OSVERSION)-$(ARCH) --build-arg OSVERSION=$(OSVERSION) \
--build-arg ARCH=$(ARCH) -f ./pkg/smbplugin/Windows.Dockerfile .
--build-arg ARCH=$(ARCH) -f ./cmd/smbplugin/Windows.Dockerfile .

.PHONY: container-all
container-all: smb-windows
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions pkg/smbplugin/README.md → cmd/smbplugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ ver=v0.6.0

linux="linux-amd64"
make smb
az acr build -r $acrName -t $acrRepo:$ver-$linux -f pkg/smbplugin/Dockerfile --platform linux .
az acr build -r $acrName -t $acrRepo:$ver-$linux -f cmd/smbplugin/Dockerfile --platform linux .

win="windows-1809-amd64"
make smb-windows
az acr build -r $acrName -t $acrRepo:$ver-$win -f pkg/smbplugin/Windows.Dockerfile --platform windows .
az acr build -r $acrName -t $acrRepo:$ver-$win -f cmd/smbplugin/Windows.Dockerfile --platform windows .

docker manifest create $acrRepo:$ver $acrRepo:$ver-$linux $acrRepo:$ver-$win
docker manifest inspect $acrRepo:$ver
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion hack/release-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fi

export REGISTRY_NAME="$1"
export REGISTRY=$REGISTRY_NAME.azurecr.io
export IMAGE_NAME=public/k8s/csi/smb-csi
export IMAGENAME=public/k8s/csi/smb-csi
export CI=1
export PUBLISH=1

Expand Down

0 comments on commit 2e8e6b4

Please sign in to comment.