Skip to content

Commit 88d2306

Browse files
committed
Refactor: refactor vela-prism dockerfile for arm arch
Signed-off-by: Yin Da <[email protected]>
1 parent c12eae9 commit 88d2306

File tree

2 files changed

+14
-25
lines changed

2 files changed

+14
-25
lines changed

.github/workflows/build-image.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ jobs:
2424
with:
2525
images: |
2626
oamdev/vela-prism
27-
ghcr.io/oam-dev/vela-prism
27+
ghcr.io/kubevela/oamdev/vela-prism
2828
tags: |
29-
type=ref,event=branch
3029
type=ref,event=tag
3130
type=raw,value=latest,enable={{is_default_branch}}
3231
- name: Login docker.io

cmd/apiserver/Dockerfile

+13-23
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
ARG BASE_IMAGE
22
# Build the manager binary
3-
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.19-alpine as builder
4-
ARG GOPROXY
5-
ENV GOPROXY=${GOPROXY:-https://goproxy.cn}
3+
FROM golang:1.19-alpine as builder
4+
ARG OS
5+
ARG ARCH
6+
67
WORKDIR /workspace
78
# Copy the Go Modules manifests
89
COPY go.mod go.mod
@@ -15,31 +16,20 @@ RUN go mod download
1516
COPY cmd/apiserver/main.go cmd/apiserver/main.go
1617
COPY pkg/ pkg/
1718

18-
# Build
19-
ARG TARGETARCH
20-
21-
RUN GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} \
22-
go build -a -ldflags "-s -w" \
23-
-o vela-prism-${TARGETARCH} cmd/apiserver/main.go
24-
25-
# Before copying the Go binary directly to the final image,
26-
# add them to the intermdediate upx image
27-
FROM gruebel/upx:latest as upx
28-
ARG TARGETARCH
29-
COPY --from=builder /workspace/vela-prism-${TARGETARCH} /workspace/vela-prism-${TARGETARCH}
30-
# Compress the binary and copy it to final image
31-
RUN upx --best --lzma -o /workspace/vela-prism-${TARGETARCH}-upx /workspace/vela-prism-${TARGETARCH}
19+
RUN CGO_ENABLED=0 \
20+
GOOS=${OS} \
21+
GOARCH=${ARCH} \
22+
go build \
23+
-a -ldflags "-s -w" \
24+
-o vela-prism \
25+
cmd/apiserver/main.go
3226

33-
# Overwrite `BASE_IMAGE` by passing `--build-arg=BASE_IMAGE=gcr.io/distroless/static:nonroot`
34-
35-
FROM ${BASE_IMAGE:-alpine:3.15}
27+
FROM alpine:3.17
3628
# This is required by daemon connnecting with cri
3729
RUN apk add --no-cache ca-certificates bash expat
3830
RUN apk add curl
3931

4032
WORKDIR /
41-
42-
ARG TARGETARCH
43-
COPY --from=upx /workspace/vela-prism-${TARGETARCH}-upx /usr/local/bin/vela-prism
33+
COPY --from=builder /workspace/vela-prism /usr/local/bin/vela-prism
4434

4535
CMD ["vela-prism"]

0 commit comments

Comments
 (0)