Spaces:
Build error
Build error
File size: 1,627 Bytes
f64569f a14955b 870b940 a14955b 7e4784b a14955b 870b940 d1bc520 a14955b d1bc520 a14955b d1bc520 f64569f a14955b 870b940 a14955b f64569f a14955b 870b940 f64569f 870b940 a14955b 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 55 |
FROM node:18-alpine AS build
# Install git and dependencies needed for Puppeteer
RUN apk add --no-cache git chromium
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 for Puppeteer in production
RUN apk add --no-cache chromium
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
# 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
USER nextjs
EXPOSE 3000
# Use the start command from package.json
CMD ["npm", "start"] |