dockerfile support multiarch(amd64,arm64) (#83)
Signed-off-by: liheng.zms <liheng.zms@alibaba-inc.com> Signed-off-by: liheng.zms <liheng.zms@alibaba-inc.com>
This commit is contained in:
parent
5525846f6c
commit
f21c3fb763
|
@ -0,0 +1,26 @@
|
|||
# Build the manager binary
|
||||
FROM --platform=$BUILDPLATFORM golang:1.16 as builder
|
||||
|
||||
WORKDIR /workspace
|
||||
|
||||
# Copy the Go Modules manifests
|
||||
COPY go.mod go.mod
|
||||
COPY go.sum go.sum
|
||||
|
||||
# Copy the go source
|
||||
COPY main.go main.go
|
||||
COPY api/ api/
|
||||
COPY pkg/ pkg/
|
||||
|
||||
# Build
|
||||
ARG TARGETOS TARGETARCH
|
||||
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go
|
||||
|
||||
# Use distroless as minimal base image to package the manager binary
|
||||
# Refer to https://github.com/GoogleContainerTools/distroless for more details
|
||||
FROM gcr.io/distroless/static:nonroot
|
||||
WORKDIR /
|
||||
COPY --from=builder /workspace/manager .
|
||||
USER 65532:65532
|
||||
|
||||
ENTRYPOINT ["/manager"]
|
5
Makefile
5
Makefile
|
@ -1,6 +1,8 @@
|
|||
|
||||
# Image URL to use all building/pushing image targets
|
||||
IMG ?= controller:latest
|
||||
# Platforms to build the image for
|
||||
PLATFORMS ?= linux/amd64,linux/arm64
|
||||
|
||||
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
|
||||
ifeq (,$(shell go env GOBIN))
|
||||
|
@ -68,6 +70,9 @@ docker-build: ## Build docker image with the manager.
|
|||
docker-push: ## Push docker image with the manager.
|
||||
docker push ${IMG}
|
||||
|
||||
# Build and push the multiarchitecture docker images and manifest.
|
||||
docker-multiarch:
|
||||
docker buildx build -f ./Dockerfile_multiarch --pull --no-cache --platform=$(PLATFORMS) --push . -t $(IMG)
|
||||
##@ Deployment
|
||||
|
||||
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
|
||||
|
|
|
@ -31,7 +31,7 @@ spec:
|
|||
containers:
|
||||
- name: echoserver
|
||||
# mac m1 should choics image can support arm64,such as image e2eteam/echoserver:2.2-linux-arm64
|
||||
image: cilium/echoserver:1.10.2
|
||||
image: cilium/echoserver:1.10.2
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
|
@ -107,9 +107,7 @@ spec:
|
|||
trafficRoutings:
|
||||
# echoserver service name
|
||||
- service: echoserver
|
||||
# nginx ingress
|
||||
type: nginx
|
||||
# echoserver ingress name
|
||||
# echoserver ingress name, current only nginx ingress
|
||||
ingress:
|
||||
name: echoserver
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue