khulnasoft commited on
Commit
05b0722
·
verified ·
1 Parent(s): 5de312e

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +22 -4
Dockerfile CHANGED
@@ -8,19 +8,37 @@ RUN groupadd -r appgroup && useradd -r -g appgroup -m appuser
8
  WORKDIR /app
9
 
10
  # Change ownership of the working directory to the non-root user
11
- RUN chown -R appuser:appgroup /app
 
 
 
12
 
13
- # Switch to the non-root user
14
- USER appuser
 
 
 
 
 
 
 
 
 
 
15
 
16
  # Copy package.json and package-lock.json to the working directory
17
  COPY package*.json ./
18
 
 
 
 
 
 
19
  # Install the dependencies
20
  RUN npm ci
21
 
22
  # Copy the rest of the application code to the working directory
23
- COPY . .
24
 
25
  # Expose the port the app will run on
26
  EXPOSE 3001
 
8
  WORKDIR /app
9
 
10
  # Change ownership of the working directory to the non-root user
11
+ RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
12
+ && chown -R user:user /app
13
+ RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
14
+ USER user
15
 
16
+ # All users can use /home/user as their home directory
17
+ ENV HOME=/home/user
18
+ RUN mkdir $HOME/.cache $HOME/.config \
19
+ && chmod -R 777 $HOME
20
+
21
+ WORKDIR $HOME/app
22
+
23
+ #######################################
24
+ # Start root user section
25
+ #######################################
26
+
27
+ USER root
28
 
29
  # Copy package.json and package-lock.json to the working directory
30
  COPY package*.json ./
31
 
32
+
33
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
34
+ COPY --chown=user . $HOME/app
35
+
36
+
37
  # Install the dependencies
38
  RUN npm ci
39
 
40
  # Copy the rest of the application code to the working directory
41
+ COPY --chown=user . .
42
 
43
  # Expose the port the app will run on
44
  EXPOSE 3001