Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
chore(build): Optimize Makefile and Dockerfile.app build configuration
begoniezhaod734b80cb5ab
diff --git a/Makefile b/Makefileindex 41c3ad836..1ac93ab4d 100644--- a/Makefile+++ b/Makefile@@ -181,7 +181,7 @@ build-prod:BUILD_TIME=$${BUILD_TIME:-unknown}; \GO_VERSION=$${GO_VERSION:-unknown}; \LDFLAGS="-X 'github.com/Tencent/WeKnora/internal/handler.Version=$$VERSION' -X 'github.com/Tencent/WeKnora/internal/handler.CommitID=$$COMMIT_ID' -X 'github.com/Tencent/WeKnora/internal/handler.BuildTime=$$BUILD_TIME' -X 'github.com/Tencent/WeKnora/internal/handler.GoVersion=$$GO_VERSION'"; \- GOOS=linux go build -v -installsuffix cgo -ldflags="-w -s $$LDFLAGS" -o $(BINARY_NAME) $(MAIN_PATH)+ go build -ldflags="-w -s $$LDFLAGS" -o $(BINARY_NAME) $(MAIN_PATH)clean-db:@echo "Cleaning database..."diff --git a/docker/Dockerfile.app b/docker/Dockerfile.appindex 7cdc14922..ddb36e073 100644--- a/docker/Dockerfile.app+++ b/docker/Dockerfile.app@@ -3,10 +3,6 @@ FROM golang:1.24-alpine AS builderWORKDIR /app-# Install dependencies-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories && \- apk add --no-cache git build-base-# 通过构建参数接收敏感信息ARG GOPRIVATE_ARGARG GOPROXY_ARG@@ -17,15 +13,17 @@ ENV GOPRIVATE=${GOPRIVATE_ARG}ENV GOPROXY=${GOPROXY_ARG}ENV GOSUMDB=${GOSUMDB_ARG}-# Copy go mod and sum files-COPY go.mod go.sum ./-RUN go mod download+# Install dependencies+RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories && \+ apk add --no-cache git build-base-ENV CGO_ENABLED=1# Install migrate toolRUN go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest-# Copy source code+# Copy go mod and sum files+COPY go.mod .+COPY go.sum .+RUN go mod downloadCOPY . .# Get version and commit info for build injection@@ -53,16 +51,21 @@ RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/reapk update && apk upgrade && \apk add --no-cache build-base postgresql-client mysql-client ca-certificates tzdata sed curl bash vim wget+# Create a non-root user and switch to it+RUN mkdir -p /data/files && \+ adduser -D -g '' appuser && \+ chown -R appuser:appuser /app /data/files++# Copy migrate tool from builder stage+COPY --from=builder /go/bin/migrate /usr/local/bin/+COPY --from=builder /go/pkg/mod/github.com/yanyiwu /go/pkg/mod/github.com/yanyiwu/+# Copy the binary from the builder stage-COPY --from=builder /app/WeKnora .COPY --from=builder /app/config ./configCOPY --from=builder /app/scripts ./scriptsCOPY --from=builder /app/migrations ./migrationsCOPY --from=builder /app/dataset/samples ./dataset/samples--# Copy migrate tool from builder stage-COPY --from=builder /go/bin/migrate /usr/local/bin/-COPY --from=builder /go/pkg/mod/github.com/yanyiwu /go/pkg/mod/github.com/yanyiwu/+COPY --from=builder /app/WeKnora .# Make scripts executableRUN chmod +x ./scripts/*.sh@@ -70,14 +73,6 @@ RUN chmod +x ./scripts/*.sh# Expose portsEXPOSE 8080-# Set environment variables-ENV CGO_ENABLED=1--# Create a non-root user and switch to it-RUN mkdir -p /data/files && \- adduser -D -g '' appuser && \- chown -R appuser:appuser /app /data/files-# Switch to non-root user and run the application directlyUSER appuser