deepak191z commited on
Commit
567ad9e
·
verified ·
1 Parent(s): afdd5d6

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +10 -11
Dockerfile CHANGED
@@ -1,6 +1,6 @@
1
  FROM node:20
2
 
3
- # Create a non-root user with a home directory
4
  RUN groupadd -r appuser && useradd -m -r -g appuser appuser
5
 
6
  # Set working directory
@@ -10,21 +10,20 @@ WORKDIR /usr/src/app
10
  COPY package*.json ./
11
  RUN npm install
12
 
13
- # Switch to non-root user to install Playwright browsers in the correct home
14
- USER appuser
15
-
16
- # Set environment variable for Playwright browser path
17
  ENV PLAYWRIGHT_BROWSERS_PATH=/home/appuser/.cache/ms-playwright
18
 
19
- # Install Playwright browsers and ensure the cache directory exists
20
  RUN npx playwright install --with-deps && \
21
- mkdir -p /home/appuser/.cache/ms-playwright
 
22
 
23
- # Copy application source code
24
  COPY . .
25
 
26
- # Expose the desired port
27
- EXPOSE 7860
28
 
29
- # Start the server
 
30
  CMD ["node", "server.js"]
 
1
  FROM node:20
2
 
3
+ # Create non-root user with a home directory
4
  RUN groupadd -r appuser && useradd -m -r -g appuser appuser
5
 
6
  # Set working directory
 
10
  COPY package*.json ./
11
  RUN npm install
12
 
13
+ # Set environment variable so Playwright installs browsers in a directory we'll later assign to appuser
 
 
 
14
  ENV PLAYWRIGHT_BROWSERS_PATH=/home/appuser/.cache/ms-playwright
15
 
16
+ # Install Playwright browsers and dependencies as root
17
  RUN npx playwright install --with-deps && \
18
+ mkdir -p /home/appuser/.cache/ms-playwright && \
19
+ chown -R appuser:appuser /home/appuser/.cache/ms-playwright /usr/src/app
20
 
21
+ # Copy the rest of the application code
22
  COPY . .
23
 
24
+ # Switch to the non-root user
25
+ USER appuser
26
 
27
+ # Expose the desired port and start the server
28
+ EXPOSE 7860
29
  CMD ["node", "server.js"]