fix: update .gitignore to include package-lock.json and yarn.lock; modify Dockerfile for improved build process and dependency management

This commit is contained in:
Laisky.Cai 2025-03-12 10:50:50 +00:00
parent 3effdef34a
commit d4d534764c
9 changed files with 32718 additions and 24 deletions

View File

@ -6,6 +6,7 @@ on:
- "master"
- "main"
- "test/ci"
- fix/arm
jobs:
build_latest:
@ -126,6 +127,8 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-flags: --debug
- name: Login to Docker Hub
uses: docker/login-action@v3
@ -143,7 +146,7 @@ jobs:
build-args: |
TARGETARCH=arm64
cache-from: type=gha
# cache-to: type=gha,mode=max
cache-to: type=gha,mode=max
build_windows:
runs-on: windows-latest

View File

@ -1,27 +1,26 @@
# * for amd64: docker build -t ppcelery/one-api:arm64-latest .
# * for arm64: DOCKER_BUILDKIT=1 docker build --platform linux/arm64 --build-arg TARGETARCH=arm64 -t ppcelery/one-api:arm64-latest .
FROM node:18 AS builder
FROM node:22-bullseye AS builder
WORKDIR /web
COPY ./VERSION .
COPY ./web .
# Fix the React build issues by installing dependencies globally first
RUN npm install -g react-scripts
RUN npm install -g npm react-scripts
# Install dependencies for each project
RUN npm install --prefix /web/default & \
npm install --prefix /web/berry & \
npm install --prefix /web/air & \
wait
# do not build parallel to avoid OOM on github actions
RUN cd /web/default && yarn install
RUN cd /web/berry && yarn install
RUN cd /web/air && yarn install
RUN mkdir -p /web/build
# Build the web projects
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
# do not build parallel to avoid OOM on github actions
RUN DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat ./VERSION) npm run build --prefix /web/default
RUN DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat ./VERSION) npm run build --prefix /web/berry
RUN DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat ./VERSION) npm run build --prefix /web/air
FROM golang:1.24.1-bullseye AS builder2
@ -93,11 +92,13 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
COPY --from=ffmpeg /usr/local/bin/ffmpeg /usr/local/bin/
COPY --from=ffmpeg /usr/local/bin/ffprobe /usr/local/bin/
# Copy our application binary
COPY --from=builder2 /build/one-api /
# COPY --from=builder /web/build /web/build
# Create web directory structure and copy web assets
COPY --from=builder2 /build/web /web
# RUN if [ "${TARGETARCH}" = "arm64" ]; then \
# else \
# rm -rf /web/build \
# fi
EXPOSE 3000
WORKDIR /data

View File

@ -3,12 +3,13 @@ package router
import (
"embed"
"fmt"
"github.com/gin-gonic/gin"
"github.com/songquanpeng/one-api/common/config"
"github.com/songquanpeng/one-api/common/logger"
"net/http"
"os"
"strings"
"github.com/gin-gonic/gin"
"github.com/songquanpeng/one-api/common/config"
"github.com/songquanpeng/one-api/common/logger"
)
func SetRouter(router *gin.Engine, buildFS embed.FS) {

4
web/air/.gitignore vendored
View File

@ -22,5 +22,5 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
.idea
package-lock.json
yarn.lock
# package-lock.json
# yarn.lock

11902
web/air/yarn.lock Normal file

File diff suppressed because it is too large Load Diff

View File

@ -22,5 +22,5 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
.idea
package-lock.json
yarn.lock
# package-lock.json
# yarn.lock

10630
web/berry/yarn.lock Normal file

File diff suppressed because it is too large Load Diff

View File

@ -22,5 +22,5 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
.idea
package-lock.json
yarn.lock
# package-lock.json
# yarn.lock

10157
web/default/yarn.lock Normal file

File diff suppressed because it is too large Load Diff