File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change 12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
14
15
- ARG GOARCH="amd64"
16
-
17
- FROM golang:1.24 AS builder
18
- # golang envs
19
- ARG GOARCH="amd64"
20
- ARG GOOS=linux
21
- ENV CGO_ENABLED=0
15
+ # setup cross-compile env
16
+ FROM --platform=$BUILDPLATFORM golang:1.24 AS builder
17
+ ARG TARGETARCH
18
+ ARG GOARCH=${TARGETARCH} CGO_ENABLED=0
22
19
20
+ # cache go modules
23
21
WORKDIR /go/src/app
24
- COPY . .
22
+ COPY go.mod go.sum .
25
23
RUN go mod download
26
- RUN CGO_ENABLED=0 go build -o /go/bin/dranet ./cmd/dranet
27
24
25
+ # build
26
+ COPY . .
27
+ RUN go build -o /go/bin/dranet ./cmd/dranet
28
+
29
+ # copy binary onto base image
28
30
FROM gcr.io/distroless/base-debian12
29
31
COPY --from=builder --chown=root:root /go/bin/dranet /dranet
30
32
CMD ["/dranet" ]
You can’t perform that action at this time.
0 commit comments