-
Notifications
You must be signed in to change notification settings - Fork 118
feat: 优化docker镜像构建逻辑,预计可从原来33分钟提升到十分钟之内 #315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2c4fa03
refactor(docker): 优化Docker构建流程,支持多平台编译
eryajf a548a88
refactor(workflow): 更新DockerHub和AliHub用户名及镜像仓库名称,移除冗余构建步骤
eryajf bef455f
refactor(workflow): 简化CI流程,移除GHCR推送并更新actions版本
eryajf 953dcc2
refactor(docker): 合并RUN指令并优化helm安装流程
eryajf 46fde7f
refactor(workflow): 更新actions版本至v5/v3并调整阿里云镜像仓库名称
eryajf 2668936
refactor(workflow): 更新DockerHub和AliHub用户名及镜像仓库名称,启用GHCR推送并添加相关标签
eryajf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -17,7 +17,6 @@ fabric.properties | |
| go.work | ||
| k8m | ||
| tmp/ | ||
| bin/ | ||
| /def.json | ||
| /example.json | ||
| /uploads/ | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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,41 +1,21 @@ | ||
| FROM golang:1.24-alpine AS golang-builder | ||
| ARG VERSION | ||
| ARG GIT_COMMIT | ||
| ARG MODEL | ||
| ARG API_KEY | ||
| ARG API_URL | ||
| ARG GIT_TAG | ||
| ARG GIT_REPOSITORY | ||
| ARG BUILD_DATE | ||
| ENV GOPROXY="https://goproxy.io" | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| ADD . . | ||
|
|
||
| RUN apk add upx | ||
| RUN --mount=type=cache,target=/go/pkg/mod \ | ||
| go build -ldflags "-s -w -X main.Version=$VERSION -X main.GitCommit=$GIT_COMMIT -X main.GitTag=$GIT_TAG -X main.GitRepo=$GIT_REPOSITORY -X main.BuildDate=$BUILD_DATE -X main.InnerModel=$MODEL -X main.InnerApiKey=$API_KEY -X main.InnerApiUrl=$API_URL" -o k8m . && apk add upx && upx -9 k8m | ||
|
|
||
| ### build final image | ||
| FROM alpine:3.21 | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| ENV BINARY_NAME=k8m | ||
| ENV TZ=Asia/Shanghai | ||
|
|
||
| COPY --from=golang-builder /app/k8m . | ||
| ARG TARGETOS | ||
| ARG TARGETARCH | ||
|
|
||
| RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \ | ||
| && apk upgrade && apk add --no-cache curl bash inotify-tools alpine-conf busybox-extras tzdata aws-cli tar gzip\ | ||
| && apk del alpine-conf && rm -rf /var/cache/* && chmod +x k8m | ||
| ADD reload.sh /app/reload.sh | ||
| RUN chmod +x /app/reload.sh | ||
| ADD reload.sh reload.sh | ||
| COPY ./bin/${BINARY_NAME}-${TARGETOS}-${TARGETARCH} ${BINARY_NAME} | ||
|
|
||
| RUN export VERIFY_CHECKSUM=false&&curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash | ||
| RUN helm version | ||
| RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \ | ||
| && apk upgrade && apk add --no-cache curl bash inotify-tools alpine-conf busybox-extras tzdata aws-cli helm tar gzip\ | ||
| && apk del alpine-conf && rm -rf /var/cache/* && chmod +x k8m && chmod +x /app/reload.sh | ||
|
|
||
| #k8m Server | ||
| EXPOSE 3618 | ||
|
|
||
| ENTRYPOINT ["/app/reload.sh","k8m","/app"] | ||
| ENTRYPOINT ["/app/reload.sh", "k8m", "/app"] |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
严重:将 OPENAI_API_KEY 烘焙进镜像二进制(泄露机密)
与 release 流程同样问题:密钥通过 -ldflags 注入,最终进入公开镜像。
删除编译期注入的 API_KEY,运行期通过环境变量注入:
随后在部署时以 env 方式传入 OPENAI_API_KEY(不写入镜像/二进制)。
我可以同步给出应用读取环境变量的代码改动建议。
📝 Committable suggestion
🤖 Prompt for AI Agents