circulartext commited on
Commit
4754470
1 Parent(s): e1842cd

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -3
Dockerfile CHANGED
@@ -11,11 +11,26 @@ COPY . /app
11
  COPY --from=circulartextapp/readspaceout /etc/passwd /etc/passwd
12
  COPY --from=circulartextapp/readspaceout /etc/group /etc/group
13
 
14
- # Set appropriate permissions for the application directory using UID and GID
15
- RUN if getent passwd user > /dev/null 2>&1 && getent group user > /dev/null 2>&1; then \
16
- chown -R "$USER_ID":"$USER_GROUP" /app && chmod -R 755 /app; \
 
 
 
 
 
 
 
 
 
 
 
 
17
  fi
18
 
 
 
 
19
  # Install gosu (adjust the package manager based on your base image)
20
  RUN apt-get update && apt-get install -y gosu && rm -rf /var/lib/apt/lists/*
21
 
 
11
  COPY --from=circulartextapp/readspaceout /etc/passwd /etc/passwd
12
  COPY --from=circulartextapp/readspaceout /etc/group /etc/group
13
 
14
+ # Set the user environment variables
15
+ ARG USER_ID=1000
16
+ ARG USER_GROUP=user
17
+ ENV USER_ID=$USER_ID \
18
+ USER_GROUP=$USER_GROUP
19
+
20
+ # Check if the user already exists
21
+ RUN if [ -z "$USER_ID" ]; then \
22
+ echo "User ID not provided. Using the default user ID 1000."; \
23
+ USER_ID=1000; \
24
+ fi && \
25
+ if id "$USER_ID" >/dev/null 2>&1; then \
26
+ echo "User with ID $USER_ID already exists."; \
27
+ else \
28
+ useradd -m -u "$USER_ID" -g "$USER_GROUP" user; \
29
  fi
30
 
31
+ # Set appropriate permissions for the application directory
32
+ RUN chown -R "$USER_ID":"$USER_GROUP" /app && chmod -R 755 /app
33
+
34
  # Install gosu (adjust the package manager based on your base image)
35
  RUN apt-get update && apt-get install -y gosu && rm -rf /var/lib/apt/lists/*
36