mirror of https://github.com/kubevela/kubevela.git
add apiserver to Dockerfile
This commit is contained in:
parent
fa57fcf66e
commit
bf93bf5004
|
|
@ -11,6 +11,7 @@ RUN go mod download
|
|||
|
||||
# Copy the go source
|
||||
COPY cmd/core/main.go main.go
|
||||
COPY cmd/apiserver/main.go cmd/apiserver/main.go
|
||||
COPY apis/ apis/
|
||||
COPY pkg/ pkg/
|
||||
COPY version/ version/
|
||||
|
|
@ -23,6 +24,10 @@ RUN GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} \
|
|||
go build -a -ldflags "-s -w -X github.com/oam-dev/kubevela/version.VelaVersion=${VERSION:-undefined} -X github.com/oam-dev/kubevela/version.GitRevision=${GITVERSION:-undefined}" \
|
||||
-o manager-${TARGETARCH} main.go
|
||||
|
||||
RUN GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} \
|
||||
go build -a -ldflags "-s -w -X github.com/oam-dev/kubevela/version.VelaVersion=${VERSION:-undefined} -X github.com/oam-dev/kubevela/version.GitRevision=${GITVERSION:-undefined}" \
|
||||
-o apiserver-${TARGETARCH} cmd/apiserver/main.go
|
||||
|
||||
# Use alpine as base image due to the discussion in issue #1448
|
||||
# You can replace distroless as minimal base image to package the manager binary
|
||||
# Refer to https://github.com/GoogleContainerTools/distroless for more details
|
||||
|
|
@ -36,6 +41,7 @@ WORKDIR /
|
|||
|
||||
ARG TARGETARCH
|
||||
COPY --from=builder /workspace/manager-${TARGETARCH} /usr/local/bin/manager
|
||||
COPY --from=builder /workspace/apiserver-${TARGETARCH} /usr/local/bin/apiserver
|
||||
|
||||
COPY entrypoint.sh /usr/local/bin/
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import (
|
|||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/oam-dev/kubevela/pkg/apiserver/version"
|
||||
"github.com/oam-dev/kubevela/version"
|
||||
)
|
||||
|
||||
// CLI for apiserver
|
||||
|
|
@ -42,7 +42,7 @@ func NewCLI(name, desc string) *CLI {
|
|||
Use: "version",
|
||||
Short: "Print the information of current binary.",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println(version.Get())
|
||||
fmt.Println("KubeVela information:", "version", version.VelaVersion, ", gitRevision", version.GitRevision)
|
||||
},
|
||||
}
|
||||
a.rootCmd.AddCommand(versionCmd)
|
||||
|
|
|
|||
|
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
Copyright 2021 The KubeVela Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package version
|
||||
|
||||
import "fmt"
|
||||
|
||||
const unspecified = "unspecified"
|
||||
|
||||
var (
|
||||
gitCommit = unspecified
|
||||
buildDate = unspecified
|
||||
version = unspecified
|
||||
)
|
||||
|
||||
// Info for git information
|
||||
type Info struct {
|
||||
Version string
|
||||
GitCommit string
|
||||
BuildDate string
|
||||
}
|
||||
|
||||
// Get get info for git
|
||||
func Get() Info {
|
||||
i := Info{
|
||||
Version: version,
|
||||
GitCommit: gitCommit,
|
||||
BuildDate: buildDate,
|
||||
}
|
||||
if i.Version == "{version}" {
|
||||
i.Version = unspecified
|
||||
}
|
||||
if i.GitCommit == "{gitCommit}" {
|
||||
i.GitCommit = unspecified
|
||||
}
|
||||
if i.BuildDate == "{buildDate}" {
|
||||
i.BuildDate = unspecified
|
||||
}
|
||||
return i
|
||||
}
|
||||
|
||||
func (i Info) String() string {
|
||||
return fmt.Sprintf(
|
||||
"Version: %s, GitCommit: %s, BuildDate: %s",
|
||||
i.Version,
|
||||
i.GitCommit,
|
||||
i.BuildDate,
|
||||
)
|
||||
}
|
||||
Loading…
Reference in New Issue