Spaces:
Build error
Build error
Update Dockerfile
Browse files- Dockerfile +19 -9
Dockerfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
FROM node:
|
2 |
|
3 |
# Install git
|
4 |
RUN apk add --no-cache git
|
@@ -8,19 +8,24 @@ WORKDIR /app
|
|
8 |
# Clone the repository
|
9 |
RUN git clone https://github.com/al1abb/invoify .
|
10 |
|
11 |
-
# Install dependencies
|
12 |
-
|
13 |
-
RUN npm install --no-fund --no-audit
|
14 |
-
# You can optionally try to update glob to a newer version
|
15 |
-
# RUN npm install glob@latest --save-dev
|
16 |
-
RUN npm run build
|
17 |
|
|
|
|
|
18 |
|
19 |
-
|
|
|
|
|
|
|
|
|
20 |
|
21 |
RUN addgroup --system --gid 1001 nodejs
|
22 |
RUN adduser --system --uid 1001 nextjs
|
23 |
|
|
|
|
|
|
|
24 |
COPY --from=build --chown=nextjs:nodejs /app/.next ./.next
|
25 |
COPY --from=build --chown=nextjs:nodejs /app/node_modules ./node_modules
|
26 |
COPY --from=build --chown=nextjs:nodejs /app/package.json ./package.json
|
@@ -28,5 +33,10 @@ COPY --from=build --chown=nextjs:nodejs /app/public ./public
|
|
28 |
|
29 |
USER nextjs
|
30 |
|
|
|
|
|
|
|
31 |
EXPOSE 3000
|
32 |
-
|
|
|
|
|
|
1 |
+
FROM node:18-alpine AS build
|
2 |
|
3 |
# Install git
|
4 |
RUN apk add --no-cache git
|
|
|
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
|
19 |
+
|
20 |
+
|
21 |
+
FROM node:18-alpine AS production
|
22 |
|
23 |
RUN addgroup --system --gid 1001 nodejs
|
24 |
RUN adduser --system --uid 1001 nextjs
|
25 |
|
26 |
+
WORKDIR /app
|
27 |
+
|
28 |
+
# Copy only what's needed for production
|
29 |
COPY --from=build --chown=nextjs:nodejs /app/.next ./.next
|
30 |
COPY --from=build --chown=nextjs:nodejs /app/node_modules ./node_modules
|
31 |
COPY --from=build --chown=nextjs:nodejs /app/package.json ./package.json
|
|
|
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
|
42 |
+
CMD ["npm", "start"]
|