From 0e08ce90dd5fd6322f325d944155d4a9b12dfd1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=81nis=20Bebr=C4=ABtis?= Date: Wed, 4 Sep 2024 21:19:04 +0300 Subject: [PATCH] Multistage build --- Makefile | 9 ++++++--- README.md | 11 +++-------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index f0fa71a..2d5848d 100644 --- a/Makefile +++ b/Makefile @@ -17,17 +17,20 @@ REGISTRY_NAME=wunderio IMAGE_NAME=csi-rclone IMAGE_TAG=$(REGISTRY_NAME)/$(IMAGE_NAME):$(VERSION) -.PHONY: all rclone-plugin clean rclone-container +.PHONY: all clean -all: plugin container push +all: build push plugin: go mod download CGO_ENABLED=0 GOOS=linux go build -a -gcflags=-trimpath=$(go env GOPATH) -asmflags=-trimpath=$(go env GOPATH) -ldflags '-X github.com/wunderio/csi-rclone/pkg/rclone.DriverVersion=$(VERSION) -extldflags "-static"' -o _output/csi-rclone-plugin ./cmd/csi-rclone-plugin - + container: docker build -t $(IMAGE_TAG) -f ./cmd/csi-rclone-plugin/Dockerfile . +build: + docker build -t $(IMAGE_TAG) -f ./Dockerfile . + push: docker push $(IMAGE_TAG) diff --git a/README.md b/README.md index 8f347c3..afacb93 100644 --- a/README.md +++ b/README.md @@ -101,17 +101,12 @@ Current code is referencing projects repository on github.com. If you fork the r 1. First push the changed code to remote. The build will use paths from `pkg/` directory. -2. Build the plugin +2. Build the plugin via multistage build and create docker image. `VERSION` file will be used as image tag. ``` -make plugin +make build ``` -3. Build the container and inject the plugin into it. -``` -make container -``` - -4. Change docker.io account in `Makefile` and use `make push` to push the image to remote. +3. Change docker.io account in `Makefile` and use `make push` to push the image to remote. ``` make push ```