Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files- Dockerfile +26 -12
Dockerfile
CHANGED
|
@@ -8,29 +8,43 @@ RUN mkdir -p /app /app/logs && \
|
|
| 8 |
# Set working directory
|
| 9 |
WORKDIR /app
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
# Switch to non-root user
|
| 12 |
USER node
|
| 13 |
|
| 14 |
# Install dependencies
|
| 15 |
-
|
| 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 |
-
#
|
| 29 |
-
|
| 30 |
-
cp -r /app/libs/proto/*.proto /app/dist/libs/proto/
|
| 31 |
|
| 32 |
-
#
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
# Expose app port
|
| 36 |
EXPOSE 8080
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
# Set working directory
|
| 9 |
WORKDIR /app
|
| 10 |
|
| 11 |
+
# Copy package files first for better caching
|
| 12 |
+
COPY --chown=node:node package*.json ./
|
| 13 |
+
COPY --chown=node:node ./apps/apigateway/package*.json ./apps/apigateway/
|
| 14 |
+
COPY --chown=node:node ./libs/proto ./libs/proto
|
| 15 |
+
|
| 16 |
# Switch to non-root user
|
| 17 |
USER node
|
| 18 |
|
| 19 |
# Install dependencies
|
| 20 |
+
RUN npm ci
|
|
|
|
| 21 |
|
| 22 |
# Copy the rest of the app's source code
|
| 23 |
+
COPY --chown=node:node . .
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
# Build the NestJS app
|
| 26 |
RUN npm run build:apigateway
|
| 27 |
|
| 28 |
+
# Create production image
|
| 29 |
+
FROM node:20-alpine
|
|
|
|
| 30 |
|
| 31 |
+
# Create app directory and set permissions
|
| 32 |
+
RUN mkdir -p /app /app/logs && \
|
| 33 |
+
chown -R node:node /app
|
| 34 |
+
|
| 35 |
+
WORKDIR /app
|
| 36 |
+
|
| 37 |
+
# Copy built files from builder
|
| 38 |
+
COPY --from=builder --chown=node:node /app/dist ./dist
|
| 39 |
+
COPY --from=builder --chown=node:node /app/libs/proto ./libs/proto
|
| 40 |
+
COPY --from=builder --chown=node:node /app/package*.json ./
|
| 41 |
+
COPY --from=builder --chown=node:node /app/node_modules ./node_modules
|
| 42 |
+
|
| 43 |
+
# Switch to non-root user
|
| 44 |
+
USER node
|
| 45 |
|
| 46 |
# Expose app port
|
| 47 |
EXPOSE 8080
|
| 48 |
+
|
| 49 |
+
# Start the application
|
| 50 |
+
CMD ["node", "dist/apps/apigateway/main.js"]
|