Skip to content

Commit 362b6bb

Browse files
committed
build(docker): 增加docker镜像
1 parent 2f62966 commit 362b6bb

File tree

4 files changed

+46
-3
lines changed

4 files changed

+46
-3
lines changed

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/node_modules

Dockerfile

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
FROM node:14-alpine as stage-web-build
2+
3+
LABEL stage=stage-web-build
4+
5+
RUN apk add make
6+
7+
WORKDIR /build/ekko/web
8+
9+
COPY . .
10+
11+
RUN make build_web
12+
13+
14+
FROM golang:1.16 as stage-bin-build
15+
16+
ENV GOPROXY="https://goproxy.cn,direct"
17+
18+
LABEL stage=stage-bin-build
19+
20+
WORKDIR /build/ekko/bin
21+
22+
COPY --from=stage-web-build /build/ekko/web .
23+
24+
ENV GO111MODULE=on
25+
26+
RUN go mod download
27+
28+
RUN make build_all
29+
30+
FROM alpine:3.14
31+
32+
WORKDIR /
33+
34+
COPY --from=stage-bin-build /build/ekko/dist/usr /usr
35+
36+
EXPOSE 2019
37+
38+
USER root
39+
40+
CMD ["ekko-server"]

Makefile

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ GOARCH=$(shell go env GOARCH)
55
GOOS=$(shell go env GOOS )
66

77
BASEPATH := $(shell pwd)
8-
BUILDDIR=$(BASEPATH)/dist/bin
8+
BUILDDIR=$(BASEPATH)/dist/usr/local/bin
99
EKKODIR=$(BASEPATH)/web/ekko
1010
DASHBOARDDIR=$(BASEPATH)/web/dashboard
1111
TERMINALDIR=$(BASEPATH)/web/terminal
1212

1313

1414
MAIN= $(BASEPATH)/cmd/server/main.go
1515

16-
APP_NAME=ekko
16+
APP_NAME=ekko-server
1717

1818
GOPROXY="https://goproxy.cn,direct"
1919

@@ -28,3 +28,5 @@ build_web: build_web_ekko build_web_dashboard build_web_terminal
2828

2929
build_bin:
3030
GOOS=$(GOOS) GOARCH=$(GOARCH) $(GOBUILD) -trimpath -ldflags "-s -w" -o $(BUILDDIR)/$(GOOS)/$(GOARCH)/$(APP_NAME) $(MAIN)
31+
32+
build_all: build_web build_bin

cmd/server/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func init() {
2929
}
3030

3131
var RootCmd = &cobra.Command{
32-
Use: "ekko",
32+
Use: "ekko-server",
3333
Short: "A dashboard for kubernetes",
3434
RunE: func(cmd *cobra.Command, args []string) error {
3535
server.EmbedWebDashboard = embedWebDashboard

0 commit comments

Comments
 (0)