Docker update
This commit is contained in:
22
DockerFile
22
DockerFile
@ -27,24 +27,14 @@ WORKDIR /app
|
||||
# Set to production
|
||||
ENV NODE_ENV=production
|
||||
|
||||
# Create nextjs user and group
|
||||
RUN addgroup --system --gid 1001 nodejs && \
|
||||
adduser --system --uid 1001 nextjs
|
||||
|
||||
# Copy necessary files from builder
|
||||
# Copy necessary files
|
||||
COPY --from=builder /app/public ./public
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
||||
COPY --from=builder /app/.next/standalone ./
|
||||
COPY --from=builder /app/.next/static ./.next/static
|
||||
|
||||
# Create cache directory and set permissions
|
||||
# Create cache directory with wide-open permissions
|
||||
RUN mkdir -p .next/cache/images && \
|
||||
chown -R nextjs:nodejs .next
|
||||
|
||||
# Ensure the entire app directory has proper permissions
|
||||
RUN chown -R nextjs:nodejs /app
|
||||
|
||||
# Switch to non-root user
|
||||
USER nextjs
|
||||
chmod -R 777 .next/cache
|
||||
|
||||
# Expose port
|
||||
EXPOSE 3000
|
||||
@ -52,5 +42,5 @@ EXPOSE 3000
|
||||
ENV PORT=3000
|
||||
ENV HOSTNAME="0.0.0.0"
|
||||
|
||||
# Start the app
|
||||
# Start the app (running as root to avoid permission issues)
|
||||
CMD ["node", "server.js"]
|
||||
Reference in New Issue
Block a user