Move build-system to mutli-stage build-container
This commit is contained in:
parent
2287670f63
commit
a3414c37dd
22
Dockerfile
22
Dockerfile
@ -12,11 +12,23 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FROM debian:bullseye
|
||||
# ---- Build ----
|
||||
FROM golang:1.23-alpine AS build
|
||||
WORKDIR /build
|
||||
# Copy sources
|
||||
ADD . .
|
||||
# Get dependencies
|
||||
RUN make go-build
|
||||
# Compile
|
||||
RUN CGO_ENABLED=0 go build -a -o webdavplugin ./cmd/webdav
|
||||
|
||||
ARG binary=./bin/webdavplugin
|
||||
COPY ${binary} /webdavplugin
|
||||
|
||||
RUN apt update && apt install -y davfs2
|
||||
# ---- Release ----
|
||||
FROM alpine AS release
|
||||
# Install required packages
|
||||
RUN apk add --no-cache davfs2
|
||||
|
||||
ENTRYPOINT ["/webdavplugin"]
|
||||
# Copy build-target
|
||||
COPY --from=build /build/webdavplugin .
|
||||
|
||||
ENTRYPOINT ["/webdavplugin"]
|
||||
|
17
Makefile
17
Makefile
@ -1,17 +0,0 @@
|
||||
GIT_COMMIT = $(shell git rev-parse HEAD)
|
||||
BUILD_DATE = $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
|
||||
|
||||
PKG = github.com/sys-liqian/csi-driver-webdav
|
||||
LDFLAGS = -X ${PKG}/pkg/webdav.driverVersion=${IMAGE_VERSION} -X ${PKG}/pkg/webdav.gitCommit=${GIT_COMMIT} -X ${PKG}/pkg/webdav.buildDate=${BUILD_DATE}
|
||||
EXT_LDFLAGS = -s -w -extldflags "-static"
|
||||
|
||||
IMAGE_VERSION ?= v0.0.1
|
||||
LOCAL_REPOSITORY ?= localhost:5000
|
||||
|
||||
.PHONY: go-build
|
||||
go-build:
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH) go build -a -ldflags "${LDFLAGS} ${EXT_LDFLAGS}" -o bin/webdavplugin ./cmd/webdav
|
||||
|
||||
.PHONY: docker-build
|
||||
docker-build: go-build
|
||||
docker build --network host -t $(LOCAL_REPOSITORY)/webdavplugin:$(IMAGE_VERSION) .
|
Loading…
x
Reference in New Issue
Block a user