mirror of
https://github.com/DefectingCat/DefectingCat.github.io
synced 2025-07-15 08:41:37 +00:00
update dockerfile
fix gists script
This commit is contained in:
29
Dockerfile
29
Dockerfile
@ -5,15 +5,15 @@ FROM base AS deps
|
||||
WORKDIR /app
|
||||
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
|
||||
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
||||
# && apk add --no-cache libc6-compat
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
|
||||
&& apk add --no-cache libc6-compat
|
||||
|
||||
# Install dependencies based on the preferred package manager
|
||||
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
|
||||
RUN \
|
||||
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
|
||||
elif [ -f package-lock.json ]; then npm ci; \
|
||||
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \
|
||||
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \
|
||||
else echo "Lockfile not found." && exit 1; \
|
||||
fi
|
||||
|
||||
@ -22,16 +22,13 @@ FROM base AS builder
|
||||
WORKDIR /app
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
#RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
|
||||
# && apk update --no-cache \
|
||||
# && apk upgrade --no-cache
|
||||
|
||||
# Uncomment the following line in case you want to disable telemetry during the build.
|
||||
# ENV NEXT_TELEMETRY_DISABLED 1
|
||||
RUN yarn build-local
|
||||
|
||||
# If using npm comment out above and use below instead
|
||||
# RUN npm run build
|
||||
RUN \
|
||||
if [ -f yarn.lock ]; then yarn run build; \
|
||||
elif [ -f package-lock.json ]; then npm run build; \
|
||||
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \
|
||||
else echo "Lockfile not found." && exit 1; \
|
||||
fi
|
||||
|
||||
# Production image, copy all the files and run next
|
||||
FROM alpine AS runner
|
||||
@ -43,8 +40,6 @@ RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
||||
&& apk add nodejs --no-cache
|
||||
|
||||
ENV NODE_ENV production
|
||||
# Uncomment the following line in case you want to disable telemetry during runtime.
|
||||
# ENV NEXT_TELEMETRY_DISABLED 1
|
||||
|
||||
RUN addgroup --system --gid 1001 nodejs
|
||||
RUN adduser --system --uid 1001 nextjs
|
||||
@ -53,8 +48,6 @@ RUN adduser --system --uid 1001 nextjs
|
||||
COPY --from=builder /app/.env ./
|
||||
COPY --from=builder /app/public ./public
|
||||
|
||||
# Automatically leverage output traces to reduce image size
|
||||
# https://nextjs.org/docs/advanced-features/output-file-tracing
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
||||
|
||||
@ -63,6 +56,6 @@ USER nextjs
|
||||
EXPOSE 3000
|
||||
|
||||
ENV PORT 3000
|
||||
ENV HOSTNAME 0.0.0.0
|
||||
|
||||
CMD ["node", "server.js"]
|
||||
# CMD ["node", "server.js"]
|
||||
CMD HOSTNAME="0.0.0.0" node server.js
|
||||
|
@ -1,5 +1,6 @@
|
||||
/* @ts-check */
|
||||
import { Octokit } from 'octokit';
|
||||
import { Octokit } from '@octokit/core';
|
||||
import { restEndpointMethods } from '@octokit/plugin-rest-endpoint-methods';
|
||||
|
||||
/**
|
||||
* Get gists.
|
||||
@ -10,7 +11,8 @@ import { Octokit } from 'octokit';
|
||||
async function getGists(page, perPage) {
|
||||
const password = process.env.NEXT_PUBLIC_GITHUB_API;
|
||||
const host = process.env.NEXT_PUBLIC_GISTS_HOST ?? 'http://api.github.com';
|
||||
const octokit = new Octokit({
|
||||
const MyOctokit = Octokit.plugin(restEndpointMethods);
|
||||
const octokit = new MyOctokit({
|
||||
auth: password,
|
||||
baseUrl: host,
|
||||
});
|
||||
@ -69,7 +71,7 @@ async function generateGists() {
|
||||
const text = l.match(relMatch)?.[1];
|
||||
if (!text) return;
|
||||
const page = new URLSearchParams(l.match(linkMatch)?.[1].split('?')[1]).get(
|
||||
'page'
|
||||
'page',
|
||||
);
|
||||
pageSize[text] = Number(page);
|
||||
});
|
||||
|
Reference in New Issue
Block a user