尝试优化构建结构

This commit is contained in:
sijinhui 2024-09-26 18:42:51 +08:00
parent 06a8c01f12
commit a0e720e5ee
4 changed files with 52 additions and 22 deletions

View File

@ -28,6 +28,13 @@ jobs:
uses: docker/build-push-action@v4
with:
context: .
file: cache.Dockerfile
file: cache.install.Dockerfile
push: true
tags: sijinhui/chatgpt-next-web:installcache
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: cache.build.Dockerfile
push: true
tags: sijinhui/chatgpt-next-web:buildcache

View File

@ -1,27 +1,32 @@
FROM sijinhui/chatgpt-next-web:buildcache AS deps
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn install
FROM sijinhui/node:base AS builder
RUN apk add --no-cache git libc6-compat
ENV OPENAI_API_KEY=""
ENV GOOGLE_API_KEY=""
ENV CODE=""
#FROM sijinhui/chatgpt-next-web:installcache AS deps
#
#WORKDIR /app
#
#COPY package.json yarn.lock ./
#
#RUN yarn install
#
#FROM sijinhui/node:base AS builder
#
#RUN apk add --no-cache git libc6-compat
#
#ENV OPENAI_API_KEY=""
#ENV GOOGLE_API_KEY=""
#ENV CODE=""
#
#WORKDIR /app
#COPY . .
#COPY --from=deps /app/node_modules ./node_modules
## 避免下面那个报错
## RUN mkdir -p "/app/node_modules/tiktoken" && mkdir -p "/app/node_modules/sharp"
## RUN yarn add sharp
## ENV NEXT_SHARP_PATH /app/node_modules/sharp
#RUN yarn build
FROM sijinhui/chatgpt-next-web:buildcache as builder
WORKDIR /app
COPY . .
COPY --from=deps /app/node_modules ./node_modules
# 避免下面那个报错
# RUN mkdir -p "/app/node_modules/tiktoken" && mkdir -p "/app/node_modules/sharp"
# RUN yarn add sharp
# ENV NEXT_SHARP_PATH /app/node_modules/sharp
RUN yarn build
RUN yarn install && yarn build
FROM sijinhui/node:base AS runner
WORKDIR /app

18
cache.build.Dockerfile Normal file
View File

@ -0,0 +1,18 @@
FROM sijinhui/chatgpt-next-web:installcache AS deps
FROM sijinhui/node:base AS builder
RUN apk add --no-cache git libc6-compat
ENV OPENAI_API_KEY=""
ENV GOOGLE_API_KEY=""
ENV CODE=""
WORKDIR /app
COPY . .
COPY --from=deps /app/node_modules ./node_modules
# 避免下面那个报错
# RUN mkdir -p "/app/node_modules/tiktoken" && mkdir -p "/app/node_modules/sharp"
# RUN yarn add sharp
# ENV NEXT_SHARP_PATH /app/node_modules/sharp
RUN yarn build