Fix build issues with Coolify deployment
This commit is contained in:
parent
dc9daa9685
commit
fd341b909d
@ -25,6 +25,8 @@ services:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: webapp/Dockerfile
|
||||
args:
|
||||
- DB_URI=${DB_URI}
|
||||
container_name: infinity-webapp
|
||||
restart: always
|
||||
depends_on:
|
||||
|
||||
@ -10,11 +10,23 @@ WORKDIR /app
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY webapp .
|
||||
|
||||
# Set build-time environment variables with defaults
|
||||
ARG DB_URI
|
||||
ENV DB_URI=$DB_URI
|
||||
|
||||
# Next.js collects completely anonymous telemetry data about general usage.
|
||||
# Learn more here: https://nextjs.org/telemetry
|
||||
ENV NEXT_TELEMETRY_DISABLED 1
|
||||
|
||||
RUN npm run build
|
||||
# Disable Next.js static optimization during build
|
||||
ENV NEXT_TELEMETRY_DISABLED 1
|
||||
ENV NEXT_SHARP_PATH /tmp/node_modules/sharp
|
||||
|
||||
# If DB_URI is not set, use a dummy value for build
|
||||
RUN if [ -z "$DB_URI" ]; then \
|
||||
echo "DB_URI not set, using dummy value for build"; \
|
||||
export DB_URI="mongodb://dummy:password@localhost:27017/dummy"; \
|
||||
fi && \
|
||||
npm run build
|
||||
|
||||
# Production image, copy all the files and run next
|
||||
FROM node:18-alpine AS runner
|
||||
@ -29,7 +41,6 @@ RUN adduser --system --uid 1001 nextjs
|
||||
COPY --from=builder /app/public ./public
|
||||
|
||||
# Automatically leverage output traces to reduce image size
|
||||
# https://nextjs.org/docs/advanced-features/output-file-tracing
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
||||
|
||||
@ -40,4 +51,5 @@ EXPOSE 3000
|
||||
ENV PORT 3000
|
||||
ENV HOSTNAME "0.0.0.0"
|
||||
|
||||
# Use the runtime environment variables
|
||||
CMD ["node", "server.js"]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user