Spaces:
Runtime error
Runtime error
Bibhu Mishra
commited on
Commit
·
4a1661d
1
Parent(s):
ca41e99
Fixed docker file
Browse files- Dockerfile +24 -13
Dockerfile
CHANGED
|
@@ -10,25 +10,36 @@ RUN apk add --no-cache python3 make g++
|
|
| 10 |
# Copy package.json and package-lock.json first for caching
|
| 11 |
COPY package*.json ./
|
| 12 |
|
| 13 |
-
# Install dependencies
|
| 14 |
-
RUN
|
| 15 |
-
&& npm install --verbose
|
| 16 |
|
| 17 |
# Copy the rest of the app source code
|
| 18 |
COPY . .
|
| 19 |
|
| 20 |
-
# Build the NestJS app
|
| 21 |
-
RUN
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
#
|
| 25 |
-
|
| 26 |
-
&& cp -r libs/proto dist/libs/
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
# Expose port 8080 and start the application
|
| 33 |
EXPOSE 8080
|
| 34 |
-
CMD ["node", "dist/apps/apigateway/main.js"]
|
|
|
|
| 10 |
# Copy package.json and package-lock.json first for caching
|
| 11 |
COPY package*.json ./
|
| 12 |
|
| 13 |
+
# Install dependencies
|
| 14 |
+
RUN npm install
|
|
|
|
| 15 |
|
| 16 |
# Copy the rest of the app source code
|
| 17 |
COPY . .
|
| 18 |
|
| 19 |
+
# Build the NestJS app and ensure proto files are copied
|
| 20 |
+
RUN npm run build:apigateway \
|
| 21 |
+
# Create both relative and absolute proto paths to handle different path resolutions
|
| 22 |
+
&& mkdir -p dist/libs/proto \
|
| 23 |
+
&& cp -r libs/proto dist/libs/ \
|
| 24 |
+
&& mkdir -p /libs/proto \
|
| 25 |
+
&& cp -r libs/proto/* /libs/proto/ \
|
| 26 |
+
&& echo "Contents of dist and proto folders:" \
|
| 27 |
+
&& ls -lR dist /libs/proto
|
| 28 |
|
| 29 |
+
# Create production image
|
| 30 |
+
FROM node:20-alpine
|
|
|
|
| 31 |
|
| 32 |
+
WORKDIR /app
|
| 33 |
+
|
| 34 |
+
# Copy only the necessary files from builder
|
| 35 |
+
COPY --from=builder /app/dist ./dist
|
| 36 |
+
COPY --from=builder /app/node_modules ./node_modules
|
| 37 |
+
COPY --from=builder /app/package*.json ./
|
| 38 |
+
|
| 39 |
+
# Copy proto files to both locations to support different path resolutions
|
| 40 |
+
COPY --from=builder /app/libs/proto ./libs/proto
|
| 41 |
+
COPY --from=builder /libs/proto /libs/proto
|
| 42 |
|
| 43 |
# Expose port 8080 and start the application
|
| 44 |
EXPOSE 8080
|
| 45 |
+
CMD ["node", "dist/apps/apigateway/main.js"]
|