Spaces:
Build error
Build error
File size: 1,929 Bytes
f64569f 870b940 1454b54 a14955b 7e4784b a14955b 870b940 d1bc520 a14955b d1bc520 a14955b d1bc520 f64569f 1454b54 870b940 a14955b f64569f a14955b 1454b54 a14955b 870b940 f64569f 1454b54 870b940 1454b54 a14955b f64569f 169ba80 f64569f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
FROM node:18-alpine AS build
# Install git and dependencies needed for Puppeteer
RUN apk add --no-cache git chromium nss freetype harfbuzz ca-certificates ttf-freefont
WORKDIR /app
# Clone the repository
RUN git clone https://github.com/Bhargav-Ravinuthala/invoify.git .
# Create .npmrc file to skip Puppeteer download
RUN echo "puppeteer_skip_chromium_download=true" > .npmrc
# Set environment variables for Puppeteer
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
# Remove the postinstall script from package.json to prevent it from running
RUN sed -i 's/"postinstall": "node node_modules\/puppeteer\/install.js"/"postinstall": "echo Skipping puppeteer install"/g' package.json || echo "No puppeteer postinstall script found"
# First install all dependencies
RUN npm install
# Build the application
RUN npm run build
FROM node:18-alpine AS production
# Install chromium and dependencies for Puppeteer in production
RUN apk add --no-cache chromium nss freetype harfbuzz ca-certificates ttf-freefont
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
WORKDIR /app
# Copy only what's needed for production
COPY --from=build --chown=nextjs:nodejs /app/.next ./.next
COPY --from=build --chown=nextjs:nodejs /app/node_modules ./node_modules
COPY --from=build --chown=nextjs:nodejs /app/package.json ./package.json
COPY --from=build --chown=nextjs:nodejs /app/public ./public
COPY --from=build --chown=nextjs:nodejs /app/i18n ./i18n
# Set environment variables for Puppeteer in production
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
ENV NODE_ENV production
ENV PORT 3000
# This is critical - make sure temp directories exist and are writable
RUN mkdir -p /tmp/chromium-data-dir && chmod -R 777 /tmp
USER nextjs
EXPOSE 3000
# Use the start command from package.jsonss
CMD ["npm", "start"] |