forked from jumpserver/jumpserver
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3bb433c
commit cb49af5
Showing
6 changed files
with
112 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM golang:1.21.12-alpine3.20 | ||
|
||
WORKDIR /script | ||
|
||
COPY . . | ||
|
||
# ARG APT_MIRROR=mirrors.tuna.tsinghua.edu.cn | ||
ARG APT_MIRROR=mirrors.ustc.edu.cn | ||
# ARG APT_MIRROR=mirrors.aliyun.com | ||
RUN sed -i "[email protected]@${APT_MIRROR}@g" /etc/apk/repositories \ | ||
&& apk update && apk add build-base | ||
|
||
ARG GOPROXY=https://goproxy.io | ||
RUN go mod tidy | ||
|
||
CMD ["/bin/sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
arch="amd64" | ||
output_name="jms_cli" | ||
IMAGE_NAME="jms_script" | ||
IMAGE_TAG="v1" | ||
#### Mac | ||
echo "1. 编译 Mac 版本脚本" | ||
bash -c "CGO_ENABLED=0 GOOS=darwin GOARCH=$arch go build -o ${output_name}_mac script.go" | ||
echo "编译 Mac 版本脚本成功" | ||
|
||
# 暂不支持 | ||
#echo "" | ||
#### Windows | ||
#echo "2. 编译 Windows 版本脚本" | ||
#bash -c "CGO_ENABLED=0 GOOS=windows GOARCH=$arch go build -o ${output_name}_windows.exe script.go" | ||
#echo "编译 Windows 版本脚本成功" | ||
echo "编译 Mac 版本脚本" | ||
bash -c "CGO_ENABLED=1 GOOS=darwin GOARCH=$arch go build -o ${output_name}_darwin script.go" | ||
|
||
echo "" | ||
#### Linux | ||
echo "2. 编译 Linux 版本脚本" | ||
bash -c "CGO_ENABLED=0 GOOS=linux GOARCH=$arch go build -o ${output_name}_linux script.go" | ||
echo "编译 Linux 版本脚本成功" | ||
echo "编译 Linux 版本脚本" | ||
if docker images | grep -q "${IMAGE_NAME}[[:space:]]*${IMAGE_TAG}"; then | ||
echo "镜像 ${IMAGE_NAME}:${IMAGE_TAG} 已经存在,跳过构建镜像" | ||
else | ||
echo "镜像不存在,先构建镜像!" | ||
bash -c "docker build -t jms_script:v1 ." | ||
fi | ||
bash -c "docker run --rm -v $(pwd):/script jms_script:v1 sh build_linux.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
arch="amd64" | ||
output_name="jms_cli" | ||
#### Linux | ||
echo "编译 Linux 版本脚本" | ||
sh -c "CGO_ENABLED=1 GOOS=linux GOARCH=$arch go build -o ${output_name}_linux script.go" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters