mirror of
https://github.com/aljazceru/enclava.git
synced 2026-01-31 13:34:54 +01:00
Fix Docker build with Next.js standalone output
- Enable outputStandalone in next.config.js for better Docker compatibility - Update Dockerfile to properly copy standalone output files - Change CMD to use node server.js for standalone builds - This should resolve the @/lib module resolution issues in Docker builds
This commit is contained in:
@@ -48,10 +48,10 @@ RUN adduser --system --uid 1001 nextjs
|
||||
# Copy node_modules from deps stage
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
|
||||
# Copy built application
|
||||
# Copy built application (standalone output)
|
||||
COPY --from=builder /app/public ./public
|
||||
COPY --from=builder /app/.next ./.next
|
||||
COPY --from=builder /app/package.json ./package.json
|
||||
COPY --from=builder /app/.next/standalone ./
|
||||
COPY --from=builder /app/.next/static ./.next/static
|
||||
|
||||
# Set the correct permission for prerender cache
|
||||
RUN chown -R nextjs:nodejs .next
|
||||
@@ -64,5 +64,5 @@ EXPOSE 3000
|
||||
ENV PORT 3000
|
||||
ENV HOSTNAME "0.0.0.0"
|
||||
|
||||
# Start the application
|
||||
CMD ["npm", "start"]
|
||||
# Start the application (standalone)
|
||||
CMD ["node", "server.js"]
|
||||
@@ -10,12 +10,20 @@ const nextConfig = {
|
||||
ignoreBuildErrors: true,
|
||||
},
|
||||
experimental: {
|
||||
// Enable standalone output for better Docker compatibility
|
||||
outputStandalone: true,
|
||||
},
|
||||
webpack: (config) => {
|
||||
webpack: (config, { isServer, dev }) => {
|
||||
config.resolve.alias = {
|
||||
...config.resolve.alias,
|
||||
'@': require('path').resolve(__dirname, 'src'),
|
||||
'@': require('path').join(__dirname, 'src'),
|
||||
};
|
||||
|
||||
// Optional: Add debug logging
|
||||
if (dev) {
|
||||
console.log('Webpack alias config:', config.resolve.alias);
|
||||
}
|
||||
|
||||
return config;
|
||||
},
|
||||
env: {
|
||||
|
||||
Reference in New Issue
Block a user