diff --git a/.env.production b/.env.production index 5e0aa11..48e7ef1 100644 --- a/.env.production +++ b/.env.production @@ -1,3 +1,3 @@ # 生产环境使用的变量 -NEXT_PUBLIC_HOST = 'http://39.103.180.196:9012/' +NEXT_PUBLIC_HOST = 'http://api.indie.cn:9012' diff --git a/.env.test b/.env.test deleted file mode 100644 index 9a091bc..0000000 --- a/.env.test +++ /dev/null @@ -1,3 +0,0 @@ -# 测试环境使用的变量 - -NEXT_PUBLIC_HOST = 'http://39.103.180.196:9012/' diff --git a/.gitignore b/.gitignore index fd3dbb5..dae8d21 100644 --- a/.gitignore +++ b/.gitignore @@ -1,36 +1,37 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.js -.yarn/install-state.gz - -# testing -/coverage - -# next.js -/.next/ -/out/ - -# production -/build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# local env files -.env*.local - -# vercel -.vercel - -# typescript -*.tsbuildinfo -next-env.d.ts +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js +.yarn/install-state.gz + +# testing +/coverage + +# next.js +/.next/ +/out/ + +# production +/build + +# misc +.DS_Store +*.pem + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# local env files +.env*.local + +# vercel +.vercel + +# typescript +*.tsbuildinfo +next-env.d.ts +/dist diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..11ab1d8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,43 @@ +# Install dependencies only when needed +FROM node:alpine AS deps +# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. +RUN apk add --no-cache libc6-compat +WORKDIR /app +COPY package.json package-lock.json ./ +RUN yarn install --frozen-lockfile --registry=https://registry.npm.taobao.org + +# Rebuild the source code only when needed +FROM node:alpine AS builder +WORKDIR /app +COPY . . +COPY --from=deps /app/node_modules ./node_modules +RUN yarn build && yarn install --production --ignore-scripts --prefer-offline --registry=https://registry.npm.taobao.org + +# Production image, copy all the files and run next +FROM node:alpine AS runner +WORKDIR /app + +ENV NODE_ENV production + +RUN addgroup -g 1001 -S nodejs +RUN adduser -S nextjs -u 1001 + +# You only need to copy next.config.js if you are NOT using the default configuration +# COPY --from=builder /app/next.config.js ./ +COPY --from=builder /app/public ./public +COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next +COPY --from=builder /app/node_modules ./node_modules +COPY --from=builder /app/package.json ./package.json + +USER nextjs + +EXPOSE 3000 + +ENV PORT 3000 + +# Next.js collects completely anonymous telemetry data about general usage. +# Learn more here: https://nextjs.org/telemetry +# Uncomment the following line in case you want to disable telemetry. +# ENV NEXT_TELEMETRY_DISABLED 1 + +CMD ["node_modules/.bin/next", "start"] diff --git a/next.config.mjs b/next.config.mjs index 619e0e0..912ea71 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -1,22 +1,28 @@ /** @type {import('next').NextConfig} */ const nextConfig = { + // output: 'export', + distDir: 'dist', async rewrites() { return [ { source: '/queyueapi/:path*', - destination: `${process.env.NEXT_PUBLIC_HOST}/:path*`, + destination: `http://api.indie.cn:9012/:path*`, }, ]; }, redirects: async () => { return [ - { - source: '/', - destination: '/vol/list/all', - permanent: true, - }, + // { + // source: '/', + // destination: '/download', + // permanent: false, + // }, ]; }, + eslint: { + ignoreDuringBuilds: true, + ignoreBuildErrors: true, + }, }; export default nextConfig; diff --git a/package.json b/package.json index dcd465d..be658ec 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,9 @@ "scripts": { "dev": "next dev -p 3001", "build": "next build", - "start": "next start -p 3001", - "lint": "eslint src --fix --ext .ts,.tsx,.js,.jsx,.mdx,.md,.json,.mjs --max-warnings 0" + "start": "next start -p 80", + "lint": "eslint src --fix --ext .ts,.tsx,.js,.jsx,.mdx,.md,.json,.mjs --max-warnings 0", + "pm2start": "pm2 start npm --name queryue-website -- run start" }, "dependencies": { "lodash": "^4.17.21", diff --git a/src/app/api/auth/[...nextauth]/options.ts b/src/app/api/auth/[...nextauth]/options.ts index b193489..bc7ab77 100644 --- a/src/app/api/auth/[...nextauth]/options.ts +++ b/src/app/api/auth/[...nextauth]/options.ts @@ -30,7 +30,7 @@ const options: NextAuthOptions = { if (result.code === 200) { return result.data; } else { - console.log(`error ${result.code}/${result.messgae}`); + // console.log(`error ${result.code}/${result.messgae}`); throw new Error(`error ${result.code}/${result.messgae}`); } } catch (error) { @@ -44,7 +44,7 @@ const options: NextAuthOptions = { maxAge: 7 * 24 * 60 * 60, }, pages: { - signIn: '/', // 重定向到 /login + signIn: '/download', // 重定向到 /login }, // callbacks: { // async jwt({ token, user }) { diff --git a/src/app/download/components/DownloadCard.tsx b/src/app/download/components/DownloadCard.tsx index b926090..76ae088 100644 --- a/src/app/download/components/DownloadCard.tsx +++ b/src/app/download/components/DownloadCard.tsx @@ -34,7 +34,7 @@ export default function Footer({ platform, iconUrl, qrCode }: DownloadQrcodeCard {/* 二维码 */}