393ebf9f92
- Updated the `KnowledgeBase` struct to rename `cos_config` to `storage_config` for consistency across the application. - Implemented a custom `UnmarshalJSON` method to maintain backward compatibility with legacy responses that still use `cos_config`. - Modified various frontend components to reflect the new `storage_config` naming, ensuring seamless integration with the updated backend structure. - Enhanced Dockerfiles and service configurations to support the new storage engine setup. This update improves the clarity of storage configurations and ensures compatibility with existing data structures.
105 lines
3.1 KiB
Docker
105 lines
3.1 KiB
Docker
# Build stage
|
|
FROM golang:1.24-bookworm AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# 通过构建参数接收敏感信息
|
|
ARG GOPRIVATE_ARG
|
|
ARG GOPROXY_ARG
|
|
ARG GOSUMDB_ARG=off
|
|
ARG APK_MIRROR_ARG
|
|
|
|
# 设置Go环境变量
|
|
ENV GOPRIVATE=${GOPRIVATE_ARG}
|
|
ENV GOPROXY=${GOPROXY_ARG}
|
|
ENV GOSUMDB=${GOSUMDB_ARG}
|
|
|
|
# Install dependencies
|
|
RUN if [ -n "$APK_MIRROR_ARG" ]; then \
|
|
sed -i "s@deb.debian.org@${APK_MIRROR_ARG}@g" /etc/apt/sources.list.d/debian.sources; \
|
|
fi && \
|
|
apt-get update && \
|
|
apt-get install -y git build-essential libsqlite3-dev
|
|
|
|
# Install migrate tool
|
|
RUN go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
|
|
|
|
# Copy go mod and sum files
|
|
COPY go.mod go.sum ./
|
|
RUN --mount=type=cache,target=/go/pkg/mod go mod download
|
|
COPY cmd/download cmd/download
|
|
RUN go run cmd/download/duckdb/duckdb.go
|
|
COPY . .
|
|
|
|
# Get version and commit info for build injection
|
|
ARG VERSION_ARG
|
|
ARG COMMIT_ID_ARG
|
|
ARG BUILD_TIME_ARG
|
|
ARG GO_VERSION_ARG
|
|
|
|
# Set build-time variables
|
|
ENV VERSION=${VERSION_ARG}
|
|
ENV COMMIT_ID=${COMMIT_ID_ARG}
|
|
ENV BUILD_TIME=${BUILD_TIME_ARG}
|
|
ENV GO_VERSION=${GO_VERSION_ARG}
|
|
|
|
# Build the application with version info
|
|
RUN --mount=type=cache,target=/go/pkg/mod make build-prod
|
|
RUN --mount=type=cache,target=/go/pkg/mod cp -r /go/pkg/mod/github.com/yanyiwu/ /app/yanyiwu/
|
|
|
|
# Final stage
|
|
FROM debian:12.12-slim
|
|
|
|
WORKDIR /app
|
|
|
|
ARG APK_MIRROR_ARG
|
|
|
|
# Create a non-root user first
|
|
RUN useradd -m -s /bin/bash appuser
|
|
|
|
RUN if [ -n "$APK_MIRROR_ARG" ]; then \
|
|
sed -i "s@deb.debian.org@${APK_MIRROR_ARG}@g" /etc/apt/sources.list.d/debian.sources; \
|
|
fi && \
|
|
apt-get update && \
|
|
apt-get install -y --no-install-recommends \
|
|
build-essential postgresql-client default-mysql-client ca-certificates tzdata sed curl bash vim wget \
|
|
libsqlite3-0 \
|
|
python3 python3-pip python3-dev libffi-dev libssl-dev \
|
|
nodejs npm && \
|
|
python3 -m pip install --break-system-packages --upgrade pip setuptools wheel && \
|
|
mkdir -p /home/appuser/.local/bin && \
|
|
curl -LsSf https://astral.sh/uv/install.sh | CARGO_HOME=/home/appuser/.cargo UV_INSTALL_DIR=/home/appuser/.local/bin sh && \
|
|
chown -R appuser:appuser /home/appuser && \
|
|
ln -sf /home/appuser/.local/bin/uvx /usr/local/bin/uvx && \
|
|
chmod +x /usr/local/bin/uvx && \
|
|
apt-get clean && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
# Create data directories and set permissions
|
|
RUN mkdir -p /data/files && \
|
|
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 /app/yanyiwu/ /go/pkg/mod/github.com/yanyiwu/
|
|
|
|
# Copy the binary from the builder stage
|
|
COPY --from=builder /app/config ./config
|
|
COPY --from=builder /app/scripts ./scripts
|
|
COPY --from=builder /app/migrations ./migrations
|
|
COPY --from=builder /app/dataset/samples ./dataset/samples
|
|
COPY --from=builder /app/skills/preloaded ./skills/preloaded
|
|
COPY --from=builder /root/.duckdb /home/appuser/.duckdb
|
|
COPY --from=builder /app/WeKnora .
|
|
|
|
# Make scripts executable
|
|
RUN chmod +x ./scripts/*.sh
|
|
|
|
# Expose ports
|
|
EXPOSE 8080
|
|
|
|
# Switch to non-root user and run the application directly
|
|
USER appuser
|
|
|
|
CMD ["./WeKnora"]
|