feat : 添加本地服务启动镜像加速

This commit is contained in:
zhaieryuan 2026-04-02 10:32:34 +08:00
parent e5fb133653
commit 9d1869fe19
3 changed files with 51 additions and 13 deletions

View file

@ -1,12 +1,13 @@
services:
skill-scanner:
build: ./scanner
ports:
- "8000:8000"
environment:
SKILL_SCANNER_LLM_API_KEY: ${SKILL_SCANNER_LLM_API_KEY:-}
SKILL_SCANNER_LLM_BASE_URL: ${SKILL_SCANNER_LLM_BASE_URL:-}
SKILL_SCANNER_LLM_MODEL: ${SKILL_SCANNER_LLM_MODEL:-}
SKILL_SCANNER_LLM_API_KEY: ${SKILL_SCANNER_LLM_API_KEY:-1d4389c1d6fb42849053958dbe916c6c.YfkLCfIXhxJlrA8D}
SKILL_SCANNER_LLM_BASE_URL: ${SKILL_SCANNER_LLM_BASE_URL:-https://open.bigmodel.cn/api/paas/v4}
SKILL_SCANNER_LLM_MODEL: ${SKILL_SCANNER_LLM_MODEL:-glm-4.7}
healthcheck:
test: ["CMD", "wget", "-qO-", "http://127.0.0.1:8000/health"]
interval: 10s
@ -14,7 +15,7 @@ services:
retries: 5
postgres:
image: ${POSTGRES_IMAGE:-postgres:16-alpine}
image: ${POSTGRES_IMAGE:-postgres:17-alpine}
ports:
- "5432:5432"
environment:
@ -30,7 +31,7 @@ services:
retries: 5
redis:
image: ${REDIS_IMAGE:-redis:7-alpine}
image: ${REDIS_IMAGE:-redis:7.0-alpine}
ports:
- "6379:6379"
healthcheck:
@ -40,7 +41,7 @@ services:
retries: 5
minio:
image: ${MINIO_IMAGE:-minio/minio:latest}
image: ${MINIO_IMAGE:-minio/minio:RELEASE.2025-09-07T16-13-09Z}
ports:
- "9000:9000"
- "9001:9001"

View file

@ -2,13 +2,24 @@ FROM python:3.11-alpine
WORKDIR /app
RUN apk add --no-cache --virtual .build-deps gcc musl-dev libffi-dev && \
pip install --no-cache-dir cisco-ai-skill-scanner && \
apk del .build-deps && \
addgroup -S app && \
adduser -S app -G app && \
mkdir -p /tmp/skillhub-scans && \
chown app:app /tmp/skillhub-scans
# 原始的构建命令
#RUN apk add --no-cache --virtual .build-deps gcc musl-dev libffi-dev && \
# pip install --no-cache-dir cisco-ai-skill-scanner && \
# apk del .build-deps && \
# addgroup -S app && \
# adduser -S app -G app && \
# mkdir -p /tmp/skillhub-scans && \
# chown app:app /tmp/skillhub-scans
# 优化使用阿里云加速
# 1.使用阿里云 Alpine 镜像源加速 apk 下载
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
# 2. 只在包版本变化时重新安装(分层缓存)
#RUN apk add --no-cache gcc musl-dev libffi-dev wget && \
# pip install --no-cache-dir -i https://mirrors.aliyun.com/pypi/simple/ cisco-ai-skill-scanner && \
# apk del gcc musl-dev libffi-dev
USER app

View file

@ -0,0 +1,26 @@
package com.iflytek.skillhub.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* Web MVC configuration.
*/
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
// Handle favicon.ico requests gracefully
registry.addResourceHandler("/favicon.ico")
.addResourceLocations("classpath:/static/");
}
@Override
public void addViewControllers(ViewControllerRegistry registry) {
// Return 404 for favicon.ico to avoid error logs
registry.addRedirectViewController("/favicon.ico", "/index.html");
}
}