deepak191z commited on
Commit
5efb26b
·
verified ·
1 Parent(s): 2b10cb1

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +13 -63
Dockerfile CHANGED
@@ -1,81 +1,31 @@
1
- FROM node:20
2
 
3
- # Switch to root to manage system dependencies and user creation
4
- USER root
5
-
6
- # Install system dependencies required by Playwright and Chromium
7
- RUN apt-get update && \
8
- apt-get install -y \
9
- ca-certificates \
10
- fonts-liberation \
11
- libasound2 \
12
- libatk-bridge2.0-0 \
13
- libatk1.0-0 \
14
- libc6 \
15
- libcairo2 \
16
- libcups2 \
17
- libdbus-1-3 \
18
- libexpat1 \
19
- libfontconfig1 \
20
- libgbm1 \
21
- libgcc1 \
22
- libglib2.0-0 \
23
- libgtk-3-0 \
24
- libnspr4 \
25
- libnss3 \
26
- libpango-1.0-0 \
27
- libpangocairo-1.0-0 \
28
- libstdc++6 \
29
- libx11-6 \
30
- libx11-xcb1 \
31
- libxcb1 \
32
- libxcomposite1 \
33
- libxcursor1 \
34
- libxdamage1 \
35
- libxext6 \
36
- libxfixes3 \
37
- libxi6 \
38
- libxrandr2 \
39
- libxrender1 \
40
- libxss1 \
41
- libxtst6 \
42
- lsb-release \
43
- wget \
44
- xdg-utils
45
-
46
- # Create non-root user
47
  RUN groupadd -r appuser && useradd -r -g appuser appuser
48
 
49
  # Set working directory
50
  WORKDIR /usr/src/app
51
 
52
- # Copy package files first for efficient layer caching
53
  COPY package*.json ./
 
54
 
55
- # Transfer ownership to appuser before installing dependencies
56
- RUN chown -R appuser:appuser /usr/src/app
57
-
58
- # Switch to non-root user for dependency installation
59
- USER appuser
60
 
61
- # Install Node.js dependencies
62
- RUN npm install
63
- RUN npm i playwright-extra puppeteer-extra-plugin-stealth
64
 
65
- # Install Playwright browsers under appuser's home directory
66
- RUN npx playwright install chromium
67
- RUN npx playwright install --with-deps
68
 
69
- # Switch back to root to copy application code
70
- USER root
71
  COPY . .
72
 
73
- # Ensure appuser owns all application files
74
  RUN chown -R appuser:appuser /usr/src/app
75
 
76
- # Switch to non-root user for runtime
77
  USER appuser
78
 
79
- # Expose port and run application
80
  EXPOSE 7860
81
- CMD ["node", "server.js"]
 
 
 
1
+ FROM node:20
2
 
3
+ # Create a non-root user
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  RUN groupadd -r appuser && useradd -r -g appuser appuser
5
 
6
  # Set working directory
7
  WORKDIR /usr/src/app
8
 
9
+ # Copy package files and install dependencies
10
  COPY package*.json ./
11
+ RUN npm install
12
 
 
 
 
 
 
13
 
 
 
 
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 7860
29
+
30
+ # Set the default command to start the server
31
+ CMD ["node", "server.js"]