Dockerfile
1 # Copyright 2025 Alibaba Group Holding Ltd. 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 15 FROM golang:1.24.0 AS builder 16 17 WORKDIR /build 18 19 ARG VERSION=dev 20 ARG GIT_COMMIT=unknown 21 ARG BUILD_TIME=unknown 22 23 COPY kubernetes ./kubernetes 24 # Prepare local modules to satisfy replace directives. 25 COPY components/internal/go.mod components/internal/go.sum ./components/internal/ 26 COPY components/ingress/go.mod components/ingress/go.sum ./components/ingress/ 27 28 WORKDIR /build 29 30 RUN cd components/internal && go mod download 31 RUN cd components/ingress && go mod download 32 33 # Copy sources. 34 COPY components/internal ./components/internal 35 COPY components/ingress/. ./components/ingress 36 37 WORKDIR /build/components/ingress 38 39 RUN CGO_ENABLED=0 go build \ 40 -ldflags "-X 'github.com/alibaba/opensandbox/internal/version.Version=${VERSION}' \ 41 -X 'github.com/alibaba/opensandbox/internal/version.BuildTime=${BUILD_TIME}' \ 42 -X 'github.com/alibaba/opensandbox/internal/version.GitCommit=${GIT_COMMIT}'" \ 43 -o /build/ingress ./main.go 44 45 FROM alpine:latest 46 47 COPY --from=builder /build/ingress . 48 49 ENTRYPOINT ["./ingress"]