diff --git a/.github/workflows/linux-release.yml b/.github/workflows/linux-release.yml index 08639b159d..774fa2c678 100644 --- a/.github/workflows/linux-release.yml +++ b/.github/workflows/linux-release.yml @@ -29,7 +29,7 @@ jobs: fi - uses: actions/setup-node@v3 with: - node-version: 16 + node-version: 24 - name: Build Frontend env: CI: "" @@ -63,4 +63,4 @@ jobs: draft: true generate_release_notes: true env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000000..d03d546f14 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,8 @@ +## [2024-01-01] + +### 优化 +- **Dockerfile**: 优化 Docker 构建,配置国内镜像加速 + - Node.js 构建阶段:配置 npm 使用 npmmirror 镜像源加速依赖下载 + - Go 构建阶段:替换 Alpine apk 为阿里云镜像加速系统包安装,配置 Go 模块代理为 goproxy.cn + - 运行时镜像:固定 Alpine 版本为 3.18,添加时区数据配置(Asia/Shanghai) + - 升级基础镜像:node:16 -> node:18-alpine,golang:alpine -> golang:1.22-alpine diff --git a/Dockerfile b/Dockerfile index 346d9c5ba7..ed9ebdffc9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,24 @@ -FROM --platform=$BUILDPLATFORM node:16 AS builder +#FROM --platform=$BUILDPLATFORM node:18-alpine AS builder +FROM node:18-alpine AS builder WORKDIR /web COPY ./VERSION . COPY ./web . -RUN npm install --prefix /web/default & \ - npm install --prefix /web/berry & \ - npm install --prefix /web/air & \ - wait +# 配置 npm 国内镜像加速 +RUN npm config set registry https://registry.npmmirror.com \ + && npm install --prefix /web/default \ + && npm install --prefix /web/berry \ + && npm install --prefix /web/air -RUN DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat ./VERSION) npm run build --prefix /web/default & \ - DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat ./VERSION) npm run build --prefix /web/berry & \ - DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat ./VERSION) npm run build --prefix /web/air & \ - wait +RUN DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat ./VERSION) npm run build --prefix /web/default \ + && DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat ./VERSION) npm run build --prefix /web/berry \ + && DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat ./VERSION) npm run build --prefix /web/air -FROM golang:alpine AS builder2 +FROM golang:1.22-alpine AS builder2 -RUN apk add --no-cache \ +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \ + && apk add --no-cache \ gcc \ musl-dev \ sqlite-dev \ @@ -24,7 +26,8 @@ RUN apk add --no-cache \ ENV GO111MODULE=on \ CGO_ENABLED=1 \ - GOOS=linux + GOOS=linux \ + GOPROXY=https://goproxy.cn,direct WORKDIR /build @@ -36,12 +39,14 @@ COPY --from=builder /web/build ./web/build RUN go build -trimpath -ldflags "-s -w -X 'github.com/songquanpeng/one-api/common.Version=$(cat VERSION)' -linkmode external -extldflags '-static'" -o one-api -FROM alpine:latest +FROM alpine:3.18 -RUN apk add --no-cache ca-certificates tzdata +RUN apk add --no-cache ca-certificates tzdata \ + && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ + && echo "Asia/Shanghai" > /etc/timezone COPY --from=builder2 /build/one-api / EXPOSE 3000 WORKDIR /data -ENTRYPOINT ["/one-api"] \ No newline at end of file +ENTRYPOINT ["/one-api"] diff --git a/VERSION b/VERSION index e69de29bb2..0e2c93950b 100644 --- a/VERSION +++ b/VERSION @@ -0,0 +1 @@ +0.7 \ No newline at end of file diff --git a/commitlint.config.js b/commitlint.config.js new file mode 100644 index 0000000000..84dcb122af --- /dev/null +++ b/commitlint.config.js @@ -0,0 +1,3 @@ +module.exports = { + extends: ['@commitlint/config-conventional'], +};