Spaces:
Running
Running
Add 3 files
Browse files- Dockerfile +57 -0
- src/pages/index.tsx +11 -0
- tsconfig.json +28 -0
Dockerfile
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
FROM node:18-alpine AS base
|
| 3 |
+
|
| 4 |
+
# Install dependencies only when needed
|
| 5 |
+
FROM base AS deps
|
| 6 |
+
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
|
| 7 |
+
RUN apk add --no-cache libc6-compat
|
| 8 |
+
WORKDIR /app
|
| 9 |
+
|
| 10 |
+
# Install dependencies based on the preferred package manager
|
| 11 |
+
COPY package.json package-lock.json* ./
|
| 12 |
+
RUN npm install
|
| 13 |
+
|
| 14 |
+
# Uncomment the following lines if you want to use a secret at buildtime,
|
| 15 |
+
# for example to access your private npm packages
|
| 16 |
+
# RUN --mount=type=secret,id=HF_EXAMPLE_SECRET,mode=0444,required=true # $(cat /run/secrets/HF_EXAMPLE_SECRET)
|
| 17 |
+
|
| 18 |
+
# Rebuild the source code only when needed
|
| 19 |
+
FROM base AS builder
|
| 20 |
+
WORKDIR /app
|
| 21 |
+
COPY --from=deps /app/node_modules ./node_modules
|
| 22 |
+
COPY . .
|
| 23 |
+
|
| 24 |
+
# Next.js collects completely anonymous telemetry data about general usage.
|
| 25 |
+
# Learn more here: https://nextjs.org/telemetry
|
| 26 |
+
# Uncomment the following line in case you want to disable telemetry during the build.
|
| 27 |
+
# ENV NEXT_TELEMETRY_DISABLED 1
|
| 28 |
+
|
| 29 |
+
RUN npm run build
|
| 30 |
+
|
| 31 |
+
# Production image, copy all the files and run next
|
| 32 |
+
FROM base AS runner
|
| 33 |
+
WORKDIR /app
|
| 34 |
+
|
| 35 |
+
ENV NODE_ENV production
|
| 36 |
+
# Uncomment the following line in case you want to disable telemetry during runtime.
|
| 37 |
+
# ENV NEXT_TELEMETRY_DISABLED 1
|
| 38 |
+
|
| 39 |
+
RUN addgroup --system --gid 1001 nodejs
|
| 40 |
+
RUN adduser --system --uid 1001 nextjs
|
| 41 |
+
|
| 42 |
+
COPY --from=builder /app/public ./public
|
| 43 |
+
|
| 44 |
+
# Automatically leverage output traces to reduce image size
|
| 45 |
+
# https://nextjs.org/docs/advanced-features/output-file-tracing
|
| 46 |
+
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
| 47 |
+
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
| 48 |
+
COPY --from=builder --chown=nextjs:nodejs /app/.next/cache ./.next/cache
|
| 49 |
+
# COPY --from=builder --chown=nextjs:nodejs /app/.next/cache/fetch-cache ./.next/cache/fetch-cache
|
| 50 |
+
|
| 51 |
+
USER nextjs
|
| 52 |
+
|
| 53 |
+
EXPOSE 3000
|
| 54 |
+
|
| 55 |
+
ENV PORT 3000
|
| 56 |
+
|
| 57 |
+
CMD ["node", "server.js"]
|
src/pages/index.tsx
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React from 'react';
|
| 2 |
+
|
| 3 |
+
const HomePage = () => {
|
| 4 |
+
return (
|
| 5 |
+
<div>
|
| 6 |
+
<h1>Hello world!</h1>
|
| 7 |
+
</div>
|
| 8 |
+
);
|
| 9 |
+
};
|
| 10 |
+
|
| 11 |
+
export default HomePage;
|
tsconfig.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"compilerOptions": {
|
| 3 |
+
"target": "ES2022",
|
| 4 |
+
"lib": ["dom", "dom.iterable", "esnext"],
|
| 5 |
+
"allowJs": true,
|
| 6 |
+
"skipLibCheck": true,
|
| 7 |
+
"strict": true,
|
| 8 |
+
"forceConsistentCasingInFileNames": true,
|
| 9 |
+
"noEmit": true,
|
| 10 |
+
"esModuleInterop": true,
|
| 11 |
+
"module": "esnext",
|
| 12 |
+
"moduleResolution": "node",
|
| 13 |
+
"resolveJsonModule": true,
|
| 14 |
+
"isolatedModules": true,
|
| 15 |
+
"jsx": "preserve",
|
| 16 |
+
"incremental": true,
|
| 17 |
+
"plugins": [
|
| 18 |
+
{
|
| 19 |
+
"name": "next"
|
| 20 |
+
}
|
| 21 |
+
],
|
| 22 |
+
"paths": {
|
| 23 |
+
"@/*": ["./src/*"]
|
| 24 |
+
}
|
| 25 |
+
},
|
| 26 |
+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
| 27 |
+
"exclude": ["node_modules"]
|
| 28 |
+
}
|