circulartext commited on
Commit
f87af42
·
1 Parent(s): e5132b5

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +33 -11
Dockerfile CHANGED
@@ -1,20 +1,42 @@
 
1
  FROM circulartextapp/readspaceout
2
 
3
- # Set up a new user named "myappuser" with user ID 1000
4
- ARG USER_ID=1000
5
- RUN addgroup --system myappgroup && adduser --system --group myappuser --uid ${USER_ID}
6
-
7
  # Set the working directory to /app
8
  WORKDIR /app
9
 
10
  # Copy the current directory contents into the container at /app
11
- COPY . .
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
- # Set permissions for the app directory
14
- RUN chown -R myappuser:myappgroup /app && chmod -R 777 /app
15
 
16
- # Switch to the "myappuser" user
17
- USER myappuser
18
 
19
- # Example CMD (modify as needed)
20
- CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--reload"]
 
1
+ # Use a suitable base Docker image with necessary dependencies
2
  FROM circulartextapp/readspaceout
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
+
10
+ # Define the user ID in the environment variable USER_ID with a default value
11
+ ARG USER_ID=1000
12
+ ENV USER_ID=$USER_ID
13
+
14
+ # Check if the user already exists
15
+ RUN if [ -z "$USER_ID" ]; then \
16
+ echo "User ID not provided. Using the default user ID 1000."; \
17
+ USER_ID=1000; \
18
+ fi && \
19
+ if id "$USER_ID" >/dev/null 2>&1; then \
20
+ echo "User with ID $USER_ID already exists."; \
21
+ else \
22
+ adduser --uid "$USER_ID" --disabled-password --gecos '' appuser; \
23
+ fi
24
+
25
+ # Set appropriate permissions for the application directory
26
+ RUN chown -R appuser:appuser /app && chmod -R 755 /app
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
+
31
+ # Set the entrypoint script as executable
32
+ COPY entrypoint.sh /usr/local/bin/entrypoint.sh
33
+ RUN chmod +x /usr/local/bin/entrypoint.sh
34
 
35
+ # Switch to the user for improved security
36
+ USER appuser
37
 
38
+ # Define the entrypoint script to handle user creation and application startup
39
+ ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
40
 
41
+ # Default command to run if the user doesn't provide a command
42
+ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--reload"]