Skip to content

Commit f50f22b

Browse files
fit2botLeeEirc
andauthored
chore: add make run target (#197)
* perf: remove code * feat: migrate to AI-native agent runtime * perf: modify reasoning * chore: add make run target --------- Co-authored-by: Eric <xplzv@126.com>
1 parent c3a4c57 commit f50f22b

127 files changed

Lines changed: 13156 additions & 6305 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Dockerfile‎

Lines changed: 14 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,21 @@
1-
FROM node:16.20-bullseye-slim as ui-build
2-
ARG TARGETARCH
3-
ARG NPM_REGISTRY="https://registry.npmmirror.com"
4-
ENV NPM_REGISTY=$NPM_REGISTRY
5-
6-
RUN set -ex \
7-
&& npm config set registry ${NPM_REGISTRY} \
8-
&& yarn config set registry ${NPM_REGISTRY}
9-
10-
WORKDIR /opt/kael/ui
11-
ADD ui/package.json ui/yarn.lock .
12-
RUN --mount=type=cache,target=/usr/local/share/.cache/yarn,sharing=locked,id=kael \
13-
yarn install
14-
15-
ADD ui .
16-
RUN --mount=type=cache,target=/usr/local/share/.cache/yarn,sharing=locked,id=kael \
17-
yarn build
18-
19-
FROM golang:1.21-bullseye as kael-build
20-
ARG TARGETARCH
1+
FROM golang:1.26-bookworm AS builder
212

223
WORKDIR /opt/kael
23-
24-
ADD go.mod go.sum .
25-
26-
ARG GOPROXY=https://goproxy.io
27-
ENV CGO_ENABLED=0
28-
ENV GO111MODULE=on
29-
ENV GOOS=linux
30-
31-
RUN --mount=type=cache,target=/root/.cache \
32-
--mount=type=cache,target=/go/pkg/mod \
33-
go mod download -x
34-
4+
COPY go.mod go.sum ./
5+
RUN --mount=type=cache,target=/go/pkg/mod go mod download
356
COPY . .
7+
ARG VERSION=dev
8+
RUN --mount=type=cache,target=/root/.cache/go-build \
9+
CGO_ENABLED=0 go build -trimpath -ldflags "-s -w -X main.Version=${VERSION}" -o /opt/kael/kael ./cmd/kael
3610

37-
ARG VERSION
38-
ENV VERSION=$VERSION
39-
40-
RUN --mount=type=cache,target=/root/.cache \
41-
--mount=type=cache,target=/go/pkg/mod \
42-
set +x \
43-
&& export GOFlAGS="-X 'main.Buildstamp=`date -u '+%Y-%m-%d %I:%M:%S%p'`'" \
44-
&& export GOFlAGS="$GOFlAGS -X 'main.Githash=`git rev-parse HEAD`'" \
45-
&& export GOFlAGS="${GOFlAGS} -X 'main.Goversion=`go version`'" \
46-
&& export GOFlAGS="$GOFlAGS -X 'main.Version=$VERSION'" \
47-
&& go build -ldflags "$GOFlAGS" -o kael ./cmd/kael \
48-
&& set -x && ls -al .
49-
50-
RUN mkdir /opt/kael/release \
51-
&& chmod +x /opt/kael/entrypoint.sh \
52-
&& mv /opt/kael/entrypoint.sh /opt/kael/release
53-
54-
FROM debian:bullseye-slim
55-
ARG TARGETARCH
56-
ENV LANG=zh_CN.UTF-8
57-
58-
ARG DEPENDENCIES=" \
59-
ca-certificates \
60-
curl \
61-
git \
62-
net-tools \
63-
unzip \
64-
vim \
65-
locales \
66-
wget"
67-
68-
ARG APT_MIRROR=http://mirrors.ustc.edu.cn
69-
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=kael \
70-
sed -i "s@http://.*.debian.org@${APT_MIRROR}@g" /etc/apt/sources.list \
71-
&& rm -f /etc/apt/apt.conf.d/docker-clean \
72-
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
73-
&& apt-get update \
74-
&& apt-get install -y --no-install-recommends ${DEPENDENCIES} \
75-
&& apt-get update \
76-
&& echo "no" | dpkg-reconfigure dash \
77-
&& echo "zh_CN.UTF-8" | dpkg-reconfigure locales \
78-
&& sed -i "s@# export @export @g" ~/.bashrc \
79-
&& sed -i "s@# alias @alias @g" ~/.bashrc \
11+
FROM debian:bookworm-slim
12+
RUN apt-get update \
13+
&& apt-get install -y --no-install-recommends ca-certificates \
8014
&& rm -rf /var/lib/apt/lists/*
81-
82-
WORKDIR /opt
83-
84-
ARG WISP_VERSION=v0.1.21
85-
RUN set -ex \
86-
&& wget https://github.com/jumpserver/wisp/releases/download/${WISP_VERSION}/wisp-${WISP_VERSION}-linux-${TARGETARCH}.tar.gz \
87-
&& tar -xf wisp-${WISP_VERSION}-linux-${TARGETARCH}.tar.gz -C /usr/local/bin/ --strip-components=1 \
88-
&& chown root:root /usr/local/bin/wisp \
89-
&& chmod 755 /usr/local/bin/wisp \
90-
&& rm -f /opt/*.tar.gz
91-
9215
WORKDIR /opt/kael
93-
94-
COPY --from=ui-build /opt/kael/ui/dist ./ui/dist
95-
COPY --from=kael-build /opt/kael/kael .
96-
COPY --from=kael-build /opt/kael/release .
97-
98-
ARG VERSION
99-
ENV VERSION=$VERSION
100-
16+
COPY --from=builder /opt/kael/kael ./kael
17+
COPY config_example.yml ./config_example.yml
18+
COPY entrypoint.sh ./entrypoint.sh
19+
RUN chmod 0755 ./entrypoint.sh ./kael
10120
EXPOSE 8083
102-
103-
CMD ["./entrypoint.sh"]
21+
ENTRYPOINT ["./entrypoint.sh"]

‎Makefile‎

Lines changed: 14 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,23 @@
1-
NAME=kael
2-
BUILDDIR=build
1+
NAME := kael
2+
BUILD_DIR := build
3+
VERSION ?= dev
4+
RUN_ARGS ?=
5+
LDFLAGS := -s -w -X main.Version=$(VERSION)
36

4-
BASEPATH := $(shell pwd)
5-
BRANCH := $(shell git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3)
6-
BUILD := $(shell git rev-parse --short HEAD)
7-
KAELSRCFILE := $(BASEPATH)/cmd/kael/
8-
9-
VERSION ?= $(BRANCH)-$(BUILD)
10-
BuildTime:= $(shell date -u '+%Y-%m-%d %I:%M:%S%p')
11-
COMMIT:= $(shell git rev-parse HEAD)
12-
GOVERSION:= $(shell go version)
13-
14-
GOOS:=$(shell go env GOOS)
15-
GOARCH:=$(shell go env GOARCH)
16-
17-
UIDIR=ui
18-
YARNINSTALL=yarn install
19-
YARNBUILD=yarn build
20-
21-
LDFLAGS=-w -s
22-
23-
KAELLDFLAGS+=-X 'main.Buildstamp=$(BuildTime)'
24-
KAELLDFLAGS+=-X 'main.Githash=$(COMMIT)'
25-
KAELLDFLAGS+=-X 'main.Goversion=$(GOVERSION)'
26-
27-
KAELBUILD=CGO_ENABLED=0 go build -trimpath -ldflags "$(KAELLDFLAGS) ${LDFLAGS}"
28-
29-
define make_artifact_full
30-
GOOS=$(1) GOARCH=$(2) $(KAELBUILD) -o $(BUILDDIR)/$(NAME)-$(1)-$(2) $(KAELSRCFILE)
31-
mkdir -p $(BUILDDIR)/$(NAME)-$(VERSION)-$(1)-$(2)/$(UIDIR)/dist/
32-
cp $(BUILDDIR)/$(NAME)-$(1)-$(2) $(BUILDDIR)/$(NAME)-$(VERSION)-$(1)-$(2)/$(NAME)
33-
-cp config_example.yml $(BUILDDIR)/$(NAME)-$(VERSION)-$(1)-$(2)/config_example.yml
34-
cp -r $(UIDIR)/dist/* $(BUILDDIR)/$(NAME)-$(VERSION)-$(1)-$(2)/$(UIDIR)/dist/
35-
cd $(BUILDDIR) && tar -czvf $(NAME)-$(VERSION)-$(1)-$(2).tar.gz $(NAME)-$(VERSION)-$(1)-$(2)
36-
rm -rf $(BUILDDIR)/$(NAME)-$(VERSION)-$(1)-$(2) $(BUILDDIR)/$(NAME)-$(1)-$(2)
37-
endef
7+
.PHONY: build run test clean docker
388

399
build:
40-
@echo "build kael"
41-
GOARCH=$(GOARCH) GOOS=$(GOOS) $(KAELBUILD) -o $(BUILDDIR)/$(NAME) $(KAELSRCFILE)
42-
43-
all: kael-ui
44-
$(call make_artifact_full,darwin,amd64)
45-
$(call make_artifact_full,darwin,arm64)
46-
$(call make_artifact_full,linux,amd64)
47-
$(call make_artifact_full,linux,arm64)
48-
$(call make_artifact_full,linux,mips64le)
49-
$(call make_artifact_full,linux,ppc64le)
50-
$(call make_artifact_full,linux,s390x)
51-
$(call make_artifact_full,linux,riscv64)
52-
53-
local: kael-ui
54-
$(call make_artifact_full,$(shell go env GOOS),$(shell go env GOARCH))
55-
56-
darwin-amd64: kael-ui
57-
$(call make_artifact_full,darwin,amd64)
58-
59-
darwin-arm64: kael-ui
60-
$(call make_artifact_full,darwin,arm64)
61-
62-
linux-amd64: kael-ui
63-
$(call make_artifact_full,linux,amd64)
64-
65-
linux-arm64: kael-ui
66-
$(call make_artifact_full,linux,arm64)
67-
68-
linux-loong64: kael-ui
69-
$(call make_artifact_full,linux,loong64)
70-
71-
linux-mips64le: kael-ui
72-
$(call make_artifact_full,linux,mips64le)
73-
74-
linux-ppc64le: kael-ui
75-
$(call make_artifact_full,linux,ppc64le)
76-
77-
linux-s390x: kael-ui
78-
$(call make_artifact_full,linux,s390x)
10+
mkdir -p $(BUILD_DIR)
11+
CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(NAME) ./cmd/kael
7912

80-
linux-riscv64: kael-ui
81-
$(call make_artifact_full,linux,riscv64)
13+
run:
14+
go run ./cmd/kael $(RUN_ARGS)
8215

83-
kael-ui:
84-
@echo "build ui"
85-
@cd $(UIDIR) && $(YARNINSTALL) && $(YARNBUILD)
16+
test:
17+
go test ./...
8618

87-
.PHONY: docker
8819
docker:
89-
@echo "build docker images"
90-
docker buildx build --build-arg VERSION=$(VERSION) -t jumpserver/kael .
20+
docker buildx build --build-arg VERSION=$(VERSION) -t jumpserver/kael:$(VERSION) .
9121

92-
.PHONY: clean
9322
clean:
94-
-rm -rf $(BUILDDIR)
95-
-rm -rf $(UIDIR)/dist/*
23+
rm -rf $(BUILD_DIR)

‎README.md‎

Lines changed: 0 additions & 56 deletions
This file was deleted.

‎cmd/kael/kael.go‎

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)