khulnasoft commited on
Commit
8270784
·
verified ·
1 Parent(s): c81b961

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +7 -24
Dockerfile CHANGED
@@ -4,37 +4,20 @@ FROM node:14
4
  # Set the working directory inside the container
5
  WORKDIR /app
6
 
7
- # Change ownership of the working directory to the non-root user
8
- RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
9
- && chown -R user:user /app
10
- USER user
11
-
12
- # All users can use /home/user as their home directory
13
- ENV HOME=/home/user
14
- RUN mkdir $HOME/.cache $HOME/.config \
15
- && chmod -R 777 $HOME
16
-
17
- WORKDIR $HOME/app
18
-
19
- #######################################
20
- # Start root user section
21
- #######################################
22
-
23
- USER root
24
-
25
  # Copy package.json and package-lock.json to the working directory
26
  COPY package*.json ./
27
 
28
-
29
- # Copy the current directory contents into the container at $HOME/app setting the owner to the user
30
- COPY --chown=user . $HOME/app
31
-
32
-
33
  # Install the dependencies
34
  RUN npm ci
35
 
36
  # Copy the rest of the application code to the working directory
37
- COPY --chown=user . .
 
 
 
 
 
 
38
 
39
  # Expose the port the app will run on
40
  EXPOSE 3001
 
4
  # Set the working directory inside the container
5
  WORKDIR /app
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  # Copy package.json and package-lock.json to the working directory
8
  COPY package*.json ./
9
 
 
 
 
 
 
10
  # Install the dependencies
11
  RUN npm ci
12
 
13
  # Copy the rest of the application code to the working directory
14
+ COPY . .
15
+
16
+ # Ensure the application directory and files have the correct permissions
17
+ RUN chmod -R 755 /app && chown -R node:node /app
18
+
19
+ # Switch to the non-root user
20
+ USER node
21
 
22
  # Expose the port the app will run on
23
  EXPOSE 3001