Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/linux-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
fi
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 24
- name: Build Frontend
env:
CI: ""
Expand Down Expand Up @@ -63,4 +63,4 @@ jobs:
draft: true
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
35 changes: 20 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
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 \
build-base

ENV GO111MODULE=on \
CGO_ENABLED=1 \
GOOS=linux
GOOS=linux \
GOPROXY=https://goproxy.cn,direct

WORKDIR /build

Expand All @@ -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"]
ENTRYPOINT ["/one-api"]
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.7
3 changes: 3 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
};