Bhargavssss commited on
Commit
870b940
·
verified ·
1 Parent(s): f64569f

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +20 -7
Dockerfile CHANGED
@@ -1,18 +1,25 @@
1
  FROM node:18-alpine AS build
2
 
3
- # Install git
4
- RUN apk add --no-cache git
5
 
6
  WORKDIR /app
7
 
8
  # Clone the repository
9
  RUN git clone https://github.com/al1abb/invoify .
10
 
11
- # Install only production dependencies to reduce memory usage
12
- RUN npm install --only=production --no-fund --no-audit
 
 
 
 
 
 
 
13
 
14
  # Install dev dependencies separately with NODE_OPTIONS to limit memory
15
- RUN NODE_OPTIONS=--max_old_space_size=512 npm install --only=dev --no-fund --no-audit
16
 
17
  # Build with memory limits
18
  RUN NODE_OPTIONS=--max_old_space_size=512 npm run build
@@ -20,6 +27,9 @@ RUN NODE_OPTIONS=--max_old_space_size=512 npm run build
20
 
21
  FROM node:18-alpine AS production
22
 
 
 
 
23
  RUN addgroup --system --gid 1001 nodejs
24
  RUN adduser --system --uid 1001 nextjs
25
 
@@ -31,11 +41,14 @@ COPY --from=build --chown=nextjs:nodejs /app/node_modules ./node_modules
31
  COPY --from=build --chown=nextjs:nodejs /app/package.json ./package.json
32
  COPY --from=build --chown=nextjs:nodejs /app/public ./public
33
 
34
- USER nextjs
35
-
 
36
  ENV NODE_ENV production
37
  ENV PORT 3000
38
 
 
 
39
  EXPOSE 3000
40
 
41
  # Use the start command from package.json
 
1
  FROM node:18-alpine AS build
2
 
3
+ # Install git and dependencies needed for Puppeteer
4
+ RUN apk add --no-cache git chromium
5
 
6
  WORKDIR /app
7
 
8
  # Clone the repository
9
  RUN git clone https://github.com/al1abb/invoify .
10
 
11
+ # Create .npmrc file to skip Puppeteer download
12
+ RUN echo "puppeteer_skip_chromium_download=true" > .npmrc
13
+
14
+ # Set environment variables for Puppeteer
15
+ ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
16
+ ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
17
+
18
+ # Install dependencies
19
+ RUN npm install --omit=dev --no-fund --no-audit
20
 
21
  # Install dev dependencies separately with NODE_OPTIONS to limit memory
22
+ RUN NODE_OPTIONS=--max_old_space_size=512 npm install --include=dev --no-fund --no-audit
23
 
24
  # Build with memory limits
25
  RUN NODE_OPTIONS=--max_old_space_size=512 npm run build
 
27
 
28
  FROM node:18-alpine AS production
29
 
30
+ # Install chromium for Puppeteer in production
31
+ RUN apk add --no-cache chromium
32
+
33
  RUN addgroup --system --gid 1001 nodejs
34
  RUN adduser --system --uid 1001 nextjs
35
 
 
41
  COPY --from=build --chown=nextjs:nodejs /app/package.json ./package.json
42
  COPY --from=build --chown=nextjs:nodejs /app/public ./public
43
 
44
+ # Set environment variables for Puppeteer in production
45
+ ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
46
+ ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
47
  ENV NODE_ENV production
48
  ENV PORT 3000
49
 
50
+ USER nextjs
51
+
52
  EXPOSE 3000
53
 
54
  # Use the start command from package.json