circulartext commited on
Commit
f3256c7
·
verified ·
1 Parent(s): 6b71af3

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -8
Dockerfile CHANGED
@@ -3,7 +3,6 @@ FROM circulartextapp/thecircworld
3
 
4
  # Set the working directory to /app
5
  WORKDIR /app
6
-
7
  # Copy the current directory contents into the container at /app
8
  COPY . /app
9
 
@@ -11,20 +10,31 @@ COPY . /app
11
  ARG USER_ID=1000
12
  ENV USER_ID=$USER_ID
13
 
14
- # Install necessary packages (using `apt` for Debian-based images)
15
- RUN apt update && apt install -y gosu
16
-
17
- # Copy the entrypoint script
18
- COPY entrypoint.sh /usr/local/bin/entrypoint.sh
19
- RUN chmod +x /usr/local/bin/entrypoint.sh
 
 
 
 
20
 
21
  # Set appropriate permissions for the application directory
22
  RUN chown -R user:user /app && chmod -R 755 /app
23
 
 
 
 
 
 
 
24
  # Switch to the user for improved security
25
  USER user
26
 
27
  # Define the entrypoint script to handle user creation and application startup
28
  ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
29
 
30
-
 
 
3
 
4
  # Set the working directory to /app
5
  WORKDIR /app
 
6
  # Copy the current directory contents into the container at /app
7
  COPY . /app
8
 
 
10
  ARG USER_ID=1000
11
  ENV USER_ID=$USER_ID
12
 
13
+ # Check if the user already exists
14
+ RUN if [ -z "$USER_ID" ]; then \
15
+ echo "User ID not provided. Using the default user ID 1000."; \
16
+ USER_ID=1000; \
17
+ fi && \
18
+ if id "$USER_ID" >/dev/null 2>&1; then \
19
+ echo "User with ID $USER_ID already exists."; \
20
+ else \
21
+ useradd -m -u "$USER_ID" user; \
22
+ fi
23
 
24
  # Set appropriate permissions for the application directory
25
  RUN chown -R user:user /app && chmod -R 755 /app
26
 
27
+
28
+ # Install gosu (adjust the package manager based on your base image)
29
+ RUN apt-get update && apt-get install -y gosu && rm -rf /var/lib/apt/lists/*
30
+ COPY entrypoint.sh /usr/local/bin/entrypoint.sh
31
+ RUN chmod +x /usr/local/bin/entrypoint.sh
32
+
33
  # Switch to the user for improved security
34
  USER user
35
 
36
  # Define the entrypoint script to handle user creation and application startup
37
  ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
38
 
39
+ # Default command to run if the user doesn't provide a command
40
+ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--reload"]