mirror of
https://github.com/DefectingCat/DefectingCat.github.io
synced 2025-07-15 16:51: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
|
WORKDIR /app
|
||||||
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
|
# 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
|
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
|
||||||
# && apk add --no-cache libc6-compat
|
&& apk add --no-cache libc6-compat
|
||||||
|
|
||||||
# Install dependencies based on the preferred package manager
|
# Install dependencies based on the preferred package manager
|
||||||
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
|
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
|
||||||
RUN \
|
RUN \
|
||||||
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
|
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
|
||||||
elif [ -f package-lock.json ]; then npm ci; \
|
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; \
|
else echo "Lockfile not found." && exit 1; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -22,16 +22,13 @@ FROM base AS builder
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=deps /app/node_modules ./node_modules
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
COPY . .
|
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.
|
RUN \
|
||||||
# ENV NEXT_TELEMETRY_DISABLED 1
|
if [ -f yarn.lock ]; then yarn run build; \
|
||||||
RUN yarn build-local
|
elif [ -f package-lock.json ]; then npm run build; \
|
||||||
|
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \
|
||||||
# If using npm comment out above and use below instead
|
else echo "Lockfile not found." && exit 1; \
|
||||||
# RUN npm run build
|
fi
|
||||||
|
|
||||||
# Production image, copy all the files and run next
|
# Production image, copy all the files and run next
|
||||||
FROM alpine AS runner
|
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
|
&& apk add nodejs --no-cache
|
||||||
|
|
||||||
ENV NODE_ENV production
|
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 addgroup --system --gid 1001 nodejs
|
||||||
RUN adduser --system --uid 1001 nextjs
|
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/.env ./
|
||||||
COPY --from=builder /app/public ./public
|
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/standalone ./
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
||||||
|
|
||||||
@ -63,6 +56,6 @@ USER nextjs
|
|||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
ENV PORT 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 */
|
/* @ts-check */
|
||||||
import { Octokit } from 'octokit';
|
import { Octokit } from '@octokit/core';
|
||||||
|
import { restEndpointMethods } from '@octokit/plugin-rest-endpoint-methods';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get gists.
|
* Get gists.
|
||||||
@ -10,7 +11,8 @@ import { Octokit } from 'octokit';
|
|||||||
async function getGists(page, perPage) {
|
async function getGists(page, perPage) {
|
||||||
const password = process.env.NEXT_PUBLIC_GITHUB_API;
|
const password = process.env.NEXT_PUBLIC_GITHUB_API;
|
||||||
const host = process.env.NEXT_PUBLIC_GISTS_HOST ?? 'http://api.github.com';
|
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,
|
auth: password,
|
||||||
baseUrl: host,
|
baseUrl: host,
|
||||||
});
|
});
|
||||||
@ -69,7 +71,7 @@ async function generateGists() {
|
|||||||
const text = l.match(relMatch)?.[1];
|
const text = l.match(relMatch)?.[1];
|
||||||
if (!text) return;
|
if (!text) return;
|
||||||
const page = new URLSearchParams(l.match(linkMatch)?.[1].split('?')[1]).get(
|
const page = new URLSearchParams(l.match(linkMatch)?.[1].split('?')[1]).get(
|
||||||
'page'
|
'page',
|
||||||
);
|
);
|
||||||
pageSize[text] = Number(page);
|
pageSize[text] = Number(page);
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user