circulartext commited on
Commit
0007fb9
·
1 Parent(s): 694e2db

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +11 -7
Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- # Use the base Docker image
2
  FROM circulartextapp/spaceread
3
 
4
  # Set the working directory to /app
@@ -7,15 +7,19 @@ WORKDIR /app
7
  # Copy the current directory contents into the container at /app
8
  COPY . /app
9
 
10
- # Set up a new user named "user" dynamically
11
- RUN if id "user" >/dev/null 2>&1; then \
12
- echo "User 'user' already exists."; \
 
 
 
 
13
  else \
14
- useradd -m user; \
15
  fi
16
 
17
  # Set appropriate permissions for the application directory
18
- RUN chown -R user:user /app && chmod -R 755 /app
19
 
20
  # Install gosu (adjust the package manager based on your base image)
21
  RUN apt-get update && apt-get install -y gosu && rm -rf /var/lib/apt/lists/*
@@ -25,7 +29,7 @@ COPY entrypoint.sh /usr/local/bin/entrypoint.sh
25
  RUN chmod +x /usr/local/bin/entrypoint.sh
26
 
27
  # Switch to the user for improved security
28
- USER user
29
 
30
  # Define the entrypoint script to handle user creation and application startup
31
  ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
 
1
+ # Use a suitable base Docker image with necessary dependencies
2
  FROM circulartextapp/spaceread
3
 
4
  # Set the working directory to /app
 
7
  # Copy the current directory contents into the container at /app
8
  COPY . /app
9
 
10
+ # Define the username in the environment variable USERNAME with a default value
11
+ ARG USERNAME=default_user
12
+ ENV USERNAME=$USERNAME
13
+
14
+ # Check if the user already exists
15
+ RUN if id "$USERNAME" >/dev/null 2>&1; then \
16
+ echo "User $USERNAME already exists."; \
17
  else \
18
+ useradd -m -u 1000 -s /bin/bash "$USERNAME"; \
19
  fi
20
 
21
  # Set appropriate permissions for the application directory
22
+ RUN chown -R "$USERNAME":"$USERNAME" /app && chmod -R 755 /app
23
 
24
  # Install gosu (adjust the package manager based on your base image)
25
  RUN apt-get update && apt-get install -y gosu && rm -rf /var/lib/apt/lists/*
 
29
  RUN chmod +x /usr/local/bin/entrypoint.sh
30
 
31
  # Switch to the user for improved security
32
+ USER "$USERNAME"
33
 
34
  # Define the entrypoint script to handle user creation and application startup
35
  ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]