mishrabp commited on
Commit
0964a6d
·
verified ·
1 Parent(s): 4a1661d

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. Dockerfile +19 -28
Dockerfile CHANGED
@@ -1,45 +1,36 @@
1
  # Use an official Node.js runtime as a parent image
2
  FROM node:20-alpine AS builder
3
 
 
 
 
 
4
  # Set working directory
5
  WORKDIR /app
6
 
7
- # Install build tools for native dependencies
8
- RUN apk add --no-cache python3 make g++
9
-
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"]
 
1
  # Use an official Node.js runtime as a parent image
2
  FROM node:20-alpine AS builder
3
 
4
+ # Create app directory and set permissions
5
+ RUN mkdir -p /app /app/logs && \
6
+ chown -R node:node /app
7
+
8
  # Set working directory
9
  WORKDIR /app
10
 
11
+ # Switch to non-root user
12
+ USER node
 
 
 
13
 
14
  # Install dependencies
15
+ COPY package*.json ./
16
  RUN npm install
17
 
18
+ # Copy the rest of the app's source code
19
  COPY . .
20
 
21
+ # Ensure proto files directory exists and copy proto files
22
+ RUN mkdir -p /app/libs/proto
23
+ COPY libs/proto/*.proto /app/libs/proto/
 
 
 
 
 
 
 
 
 
24
 
25
+ # Build the NestJS app
26
+ RUN npm run build:apigateway
27
 
28
+ # Copy proto files to dist directory
29
+ RUN mkdir -p /app/dist/libs/proto && \
30
+ cp -r /app/libs/proto/*.proto /app/dist/libs/proto/
 
31
 
32
+ # Start the application
33
+ CMD ["node", "dist/apps/apigateway/main.js"]
 
34
 
35
+ # Expose app port
36
  EXPOSE 8080