tachibanaa710 commited on
Commit
7e33654
·
verified ·
1 Parent(s): c95a2c9

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +20 -13
Dockerfile CHANGED
@@ -1,24 +1,31 @@
 
1
  FROM node:18
2
 
3
- # Install essential tools
4
- RUN apt-get update && apt-get install -y \
5
- build-essential \
6
- curl \
7
- && rm -rf /var/lib/apt/lists/*
8
 
9
- # Create app directory
10
  WORKDIR /usr/src/app
11
 
12
- # Install app dependencies
13
  COPY package*.json ./
14
- RUN npm ci --only=production
15
-
16
- # Install chrome-lens-ocr
17
  RUN npm install chrome-lens-ocr
18
 
19
- # Bundle app source
 
 
 
20
  COPY . .
21
 
22
- EXPOSE 7860
 
 
 
 
 
 
 
23
 
24
- CMD [ "node", "server.js" ]
 
 
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"]