Skip to content

Commit a415f82

Browse files
authored
Fix docker build (#828)
* fix docker build * change cmd command
1 parent ec692b1 commit a415f82

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

Dockerfile

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,10 @@ FROM base AS deps
1010
WORKDIR /app
1111

1212
# Install dependencies based on the preferred package manager
13-
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
14-
RUN \
15-
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
16-
elif [ -f package-lock.json ]; then npm ci; \
17-
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \
18-
else echo "Lockfile not found." && exit 1; \
19-
fi
13+
COPY package.json package-lock.json ./
14+
RUN npm ci
15+
RUN npm run install-idl
16+
2017

2118

2219
FROM base AS dev
@@ -37,13 +34,11 @@ COPY . .
3734
# Learn more here: https://nextjs.org/telemetry
3835
# Uncomment the following line in case you want to disable telemetry during the build.
3936
ENV NEXT_TELEMETRY_DISABLED 1
37+
# optimize Build size by inclduding only required resources
38+
ENV NEXT_CONFIG_BUILD_OUTPUT standalone
4039

41-
RUN \
42-
if [ -f yarn.lock ]; then yarn run build; \
43-
elif [ -f package-lock.json ]; then npm run build; \
44-
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \
45-
else echo "Lockfile not found." && exit 1; \
46-
fi
40+
RUN npm run generate:idl
41+
RUN npm run build
4742

4843

4944
# Production image, copy all the files and run next
@@ -72,4 +67,4 @@ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
7267
USER nextjs
7368

7469

75-
CMD ["node", "server.js"]
70+
CMD ["sh","-c", "PORT=${CADENCE_WEB_PORT:-8088} exec node server.js"]

next.config.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { fileURLToPath } from 'url';
77
const __filename = fileURLToPath(import.meta.url);
88
const __dirname = path.dirname(__filename);
99

10+
const BUILD_OUTPUT = process.env.NEXT_CONFIG_BUILD_OUTPUT === 'standalone' ? 'standalone' : undefined;
11+
1012
const nextConfig = {
1113
webpack: (config) => {
1214
config.resolve.alias = {
@@ -31,6 +33,7 @@ const nextConfig = {
3133
},
3234
];
3335
},
36+
output: BUILD_OUTPUT,
3437
experimental: {
3538
instrumentationHook: true,
3639
},

0 commit comments

Comments
 (0)