Spaces:
Paused
Paused
Update Dockerfile
Browse files- Dockerfile +20 -13
Dockerfile
CHANGED
|
@@ -1,24 +1,31 @@
|
|
|
|
|
| 1 |
FROM node:18
|
| 2 |
|
| 3 |
-
#
|
| 4 |
-
RUN
|
| 5 |
-
build-essential \
|
| 6 |
-
curl \
|
| 7 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 8 |
|
| 9 |
-
#
|
| 10 |
WORKDIR /usr/src/app
|
| 11 |
|
| 12 |
-
#
|
| 13 |
COPY package*.json ./
|
| 14 |
-
RUN npm
|
| 15 |
-
|
| 16 |
-
# Install chrome-lens-ocr
|
| 17 |
RUN npm install chrome-lens-ocr
|
| 18 |
|
| 19 |
-
#
|
|
|
|
|
|
|
|
|
|
| 20 |
COPY . .
|
| 21 |
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
|
|
|
|
|
|
| 1 |
+
# Use Node.js 18 base image
|
| 2 |
FROM node:18
|
| 3 |
|
| 4 |
+
# Create a non-root user
|
| 5 |
+
RUN groupadd -r appuser && useradd -r -g appuser appuser
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
# Set working directory
|
| 8 |
WORKDIR /usr/src/app
|
| 9 |
|
| 10 |
+
# Copy package files and install dependencies
|
| 11 |
COPY package*.json ./
|
| 12 |
+
RUN npm install
|
|
|
|
|
|
|
| 13 |
RUN npm install chrome-lens-ocr
|
| 14 |
|
| 15 |
+
# If building for production, use:
|
| 16 |
+
# RUN npm ci --only=production
|
| 17 |
+
|
| 18 |
+
# Copy application source code
|
| 19 |
COPY . .
|
| 20 |
|
| 21 |
+
# Change ownership of the app directory to the non-root user
|
| 22 |
+
RUN chown -R appuser:appuser /usr/src/app
|
| 23 |
+
|
| 24 |
+
# Switch to the non-root user
|
| 25 |
+
USER appuser
|
| 26 |
+
|
| 27 |
+
# Expose the desired port (optional, based on your server.js configuration)
|
| 28 |
+
EXPOSE 3000
|
| 29 |
|
| 30 |
+
# Set the default command to start the server
|
| 31 |
+
CMD ["node", "server.js"]
|