Skip to content

Commit f3652bb

Browse files
committed
image size fix
1 parent 409412c commit f3652bb

File tree

2 files changed

+27
-20
lines changed

2 files changed

+27
-20
lines changed

frontend/Dockerfile

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,47 @@
1+
# Use a minimal Node.js Alpine base
2+
FROM node:lts-alpine AS base
13

2-
FROM node:lts-alpine3.19 AS frontend
3-
4-
FROM frontend AS frontend-deps
5-
4+
# Dependencies Layer
5+
FROM base AS frontend-deps
66
WORKDIR /app
77
RUN apk add --no-cache libc6-compat
88

99
COPY package.json package-lock.json ./
10-
RUN npm ci -f
11-
12-
FROM frontend AS frontend-builder
10+
RUN npm ci --only=production --no-audit --no-fund
1311

12+
# Build Layer
13+
FROM base AS frontend-builder
1414
WORKDIR /app
1515
COPY --from=frontend-deps /app/node_modules ./node_modules
16-
COPY . .
16+
COPY . .
1717

18+
ENV NODE_ENV=production
1819
ENV NEXT_PUBLIC_API_URL=$API_URL
1920
ENV NEXT_PUBLIC_TYPST_COMPILER_URL=/typst-compiler.wasm
2021
ENV NEXT_PUBLIC_TYPST_RENDERER_URL=/typst-renderer.wasm
21-
22-
ENV NODE_ENV=production
2322
ENV NEXT_TELEMETRY_DISABLED=1
24-
RUN npm run build
2523

2624

27-
FROM node:22-alpine AS runner
25+
RUN npm run build
2826

27+
# Final Runner Stage (Minimal Size)
28+
FROM base AS runner
2929
WORKDIR /app
3030

31-
# 8. Copy the built application from the builder stage
32-
COPY --from=frontend-builder /app/.next ./.next
31+
# Copy only necessary files to avoid rebuilds
32+
# COPY --from=frontend-builder /app/.next ./.next
33+
# COPY --from=frontend-builder /app/public ./public
34+
# COPY --from=frontend-builder /app/package.json ./package.json
35+
3336
COPY --from=frontend-builder /app/public ./public
34-
COPY --from=frontend-builder /app/package.json /app/package-lock.json ./
37+
COPY --from=frontend-builder /app/.next/standalone ./
38+
COPY --from=frontend-builder /app/.next/static ./.next/static
3539

36-
RUN npm install --only=production --force
37-
# 9. Expose the port Next.js runs on
38-
EXPOSE 3000
40+
# RUN npm i next@15.2
41+
# COPY --from=frontend-deps /app/node_modules ./node_modules
3942

40-
# 10. Run the Next.js application
41-
CMD ["npm", "run", "start"]
43+
# Ensure we don't rebuild on start
44+
ENV NODE_ENV=production
45+
46+
EXPOSE 3000
47+
CMD ["node", "server.js"]

frontend/next.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { NextConfig } from "next";
33
const nextConfig: NextConfig = {
44
/* config options here */
55
// output: "export",
6+
output: "standalone",
67
// basePath: "/~rawick/nd"
78
};
89

0 commit comments

Comments
 (0)