diff --git a/.github/workflows/crontab_cache_to_dockerhub.yml b/.github/workflows/crontab_cache_to_dockerhub.yml new file mode 100644 index 000000000..76b5cee29 --- /dev/null +++ b/.github/workflows/crontab_cache_to_dockerhub.yml @@ -0,0 +1,26 @@ +name: Monthly Package Cache + +on: + workflow_dispatch: + schedule: + - cron: '0 4 1 * *' # 每月1号的凌晨4点 + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Check out the repo + uses: actions/checkout@v4 + - name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + file: cache.Dockerfile + push: true + tags: sijinhui/chatgpt-next-web:buildcache diff --git a/Dockerfile b/Dockerfile index 3e04d13c6..f1c5f19f8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,38 +1,8 @@ -#FROM registry.cn-hangzhou.aliyuncs.com/sijinhui/node:18-alpine AS base -FROM hub.si.icu/library/node:22.1-alpine AS base -RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories -RUN apk add --no-cache tzdata -#RUN apk add --no-cache \ -# vips-dev \ -# fftw-dev \ -# glib-dev \ -# glib \ -# expat-dev -# 设置时区环境变量 -ENV TZ=Asia/Chongqing -# 更新并安装时区工具 -RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone - -ENV PRISMA_ENGINES_MIRROR=https://registry.npmmirror.com/-/binary/prisma - -FROM base AS deps - -RUN apk add --no-cache libc6-compat - -WORKDIR /app - -COPY package.json yarn.lock ./ - -RUN yarn config set registry 'https://registry.npmmirror.com' -RUN yarn config set sharp_binary_host "https://cdn.npmmirror.com/binaries/sharp" -RUN yarn config set sharp_libvips_binary_host "https://cdn.npmmirror.com/binaries/sharp-libvips" -#RUN # 清理遗留的缓存 -#RUN yarn cache clean -RUN yarn install +FROM sijinhui/chatgpt-next-web:buildcache as deps FROM base AS builder -RUN apk add --no-cache git +RUN apk add --no-cache git libc6-compat ENV OPENAI_API_KEY="" ENV GOOGLE_API_KEY="" diff --git a/cache.Dockerfile b/cache.Dockerfile new file mode 100644 index 000000000..93b11d64a --- /dev/null +++ b/cache.Dockerfile @@ -0,0 +1,20 @@ +FROM hub.si.icu/library/node:22.1-alpine AS base +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories +RUN apk add --no-cache tzdata +# 设置时区环境变量 +ENV TZ=Asia/Chongqing +# 更新并安装时区工具 +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +RUN yarn config set registry 'https://registry.npmmirror.com' ; \ + yarn config set sharp_binary_host "https://cdn.npmmirror.com/binaries/sharp" ; \ + yarn config set sharp_libvips_binary_host "https://cdn.npmmirror.com/binaries/sharp-libvips" +ENV PRISMA_ENGINES_MIRROR=https://registry.npmmirror.com/-/binary/prisma + +FROM base AS deps + +WORKDIR /app + +COPY package.json yarn.lock ./ + +RUN yarn install