build(docker): 增加docker镜像

This commit is contained in:
Aaron3S
2021-08-09 16:40:20 +08:00
parent 2f62966491
commit 362b6bb729
4 changed files with 46 additions and 3 deletions

1
.dockerignore Normal file
View File

@@ -0,0 +1 @@
**/node_modules

40
Dockerfile Normal file
View File

@@ -0,0 +1,40 @@
FROM node:14-alpine as stage-web-build
LABEL stage=stage-web-build
RUN apk add make
WORKDIR /build/ekko/web
COPY . .
RUN make build_web
FROM golang:1.16 as stage-bin-build
ENV GOPROXY="https://goproxy.cn,direct"
LABEL stage=stage-bin-build
WORKDIR /build/ekko/bin
COPY --from=stage-web-build /build/ekko/web .
ENV GO111MODULE=on
RUN go mod download
RUN make build_all
FROM alpine:3.14
WORKDIR /
COPY --from=stage-bin-build /build/ekko/dist/usr /usr
EXPOSE 2019
USER root
CMD ["ekko-server"]

View File

@@ -5,7 +5,7 @@ GOARCH=$(shell go env GOARCH)
GOOS=$(shell go env GOOS )
BASEPATH := $(shell pwd)
BUILDDIR=$(BASEPATH)/dist/bin
BUILDDIR=$(BASEPATH)/dist/usr/local/bin
EKKODIR=$(BASEPATH)/web/ekko
DASHBOARDDIR=$(BASEPATH)/web/dashboard
TERMINALDIR=$(BASEPATH)/web/terminal
@@ -13,7 +13,7 @@ TERMINALDIR=$(BASEPATH)/web/terminal
MAIN= $(BASEPATH)/cmd/server/main.go
APP_NAME=ekko
APP_NAME=ekko-server
GOPROXY="https://goproxy.cn,direct"
@@ -28,3 +28,5 @@ build_web: build_web_ekko build_web_dashboard build_web_terminal
build_bin:
GOOS=$(GOOS) GOARCH=$(GOARCH) $(GOBUILD) -trimpath -ldflags "-s -w" -o $(BUILDDIR)/$(GOOS)/$(GOARCH)/$(APP_NAME) $(MAIN)
build_all: build_web build_bin

View File

@@ -29,7 +29,7 @@ func init() {
}
var RootCmd = &cobra.Command{
Use: "ekko",
Use: "ekko-server",
Short: "A dashboard for kubernetes",
RunE: func(cmd *cobra.Command, args []string) error {
server.EmbedWebDashboard = embedWebDashboard