Skip to content

Commit b23ed4f

Browse files
committed
add dockerfile
1 parent 6c85401 commit b23ed4f

File tree

3 files changed

+72
-1
lines changed

3 files changed

+72
-1
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ yarn-error.log*
2727

2828
# local env files
2929
.env*.local
30+
.env
31+
.dockerignore
32+
docker-compose.yml
3033

3134
# vercel
3235
.vercel

components/data-builder.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import * as cheerio from 'cheerio';
1313
import { PlusCircledIcon, MinusCircledIcon} from "@radix-ui/react-icons"
1414
import {Button} from "@/components/ui/button";
1515

16-
export function DataBuilder({ html, setHtml, defaultLayout = [265, 440, 655]}) {
16+
export function DataBuilder({ html, setHtml, defaultLayout = [265, 440, 755]}) {
1717
const [selectors, setSelectors] = useState([
1818
{"key": "title", "selector": ""}
1919
]);

dockerfile

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
FROM node:alpine AS base
2+
3+
# Step 1. Rebuild the source code only when needed
4+
FROM base AS builder
5+
6+
WORKDIR /app
7+
8+
# Install dependencies based on the preferred package manager
9+
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
10+
# Omit --production flag for TypeScript devDependencies
11+
RUN \
12+
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
13+
elif [ -f package-lock.json ]; then npm ci; \
14+
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i; \
15+
# Allow install without lockfile, so example works even without Node.js installed locally
16+
else echo "Warning: Lockfile not found. It is recommended to commit lockfiles to version control." && yarn install; \
17+
fi
18+
19+
COPY app ./app
20+
COPY components ./components
21+
COPY config ./config
22+
COPY const ./const
23+
COPY lib ./lib
24+
COPY pages ./pages
25+
COPY public ./public
26+
COPY styles ./styles
27+
COPY jsconfig.json .
28+
COPY postcss.config.js .
29+
COPY tailwind.config.js .
30+
31+
32+
# Next.js collects completely anonymous telemetry data about general usage. Learn more here: https://nextjs.org/telemetry
33+
# Uncomment the following line to disable telemetry at build time
34+
ENV NEXT_TELEMETRY_DISABLED 1
35+
36+
# Build Next.js based on the preferred package manager
37+
RUN \
38+
if [ -f yarn.lock ]; then yarn build; \
39+
elif [ -f package-lock.json ]; then npm run build; \
40+
elif [ -f pnpm-lock.yaml ]; then pnpm build; \
41+
else npm run build; \
42+
fi
43+
44+
# Note: It is not necessary to add an intermediate step that does a full copy of `node_modules` here
45+
46+
# Step 2. Production image, copy all the files and run next
47+
FROM base AS runner
48+
49+
WORKDIR /app
50+
51+
# Don't run production as root
52+
RUN addgroup --system --gid 1001 nodejs
53+
RUN adduser --system --uid 1001 nextjs
54+
USER nextjs
55+
56+
COPY --from=builder /app/public ./public
57+
58+
# Automatically leverage output traces to reduce image size
59+
# https://nextjs.org/docs/advanced-features/output-file-tracing
60+
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
61+
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
62+
63+
# Uncomment the following line to disable telemetry at run time
64+
# ENV NEXT_TELEMETRY_DISABLED 1
65+
66+
# Note: Don't expose ports here, Compose will handle that for us
67+
68+
CMD ["node", "server.js"]

0 commit comments

Comments
 (0)