circulartext commited on
Commit
42be730
·
1 Parent(s): ef8f6a5

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +27 -24
Dockerfile CHANGED
@@ -1,35 +1,38 @@
1
- # Use the base Docker image
2
- FROM circulartextapp/spaceread:latest
3
 
4
- # Set up a new user named "user" with user ID 1000
5
- RUN useradd -m -u 1000 user
6
 
7
- # Switch to the "user" user
8
- USER user
9
 
10
- # Set home to the user's home directory
11
- ENV HOME=/home/user \
12
- PATH=/home/user/.local/bin:$PATH
13
 
14
- # Set the working directory to the user's home directory
15
- WORKDIR $HOME
 
 
 
 
16
 
17
- # Copy the current directory contents into the container at /app
18
- COPY . $HOME/app
19
 
20
- # Set permissions for the app directory
21
- RUN chmod -R 777 $HOME/app
22
 
23
- # Install additional dependencies if needed
24
- # For example, if you have additional dependencies listed in requirements.txt
25
- # RUN pip install --no-cache-dir -r $HOME/app/requirements.txt
26
 
27
- # Switch back to the "user" user
28
  USER user
29
 
30
- # Set the working directory to the user's app directory
31
- WORKDIR $HOME/app
32
-
33
- # Example CMD (modify as needed)
34
- CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
35
 
 
 
 
1
+ # Use a suitable base Docker image with necessary dependencies
2
+ FROM circulartextapp/spaceread
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
11
+ ARG USER_ID
12
+ ENV USER_ID=$USER_ID
13
 
14
+ # Check if the user already exists
15
+ RUN if id "$USER_ID" >/dev/null 2>&1; then \
16
+ echo "User with ID $USER_ID already exists."; \
17
+ else \
18
+ useradd -m -u "$USER_ID" user; \
19
+ fi
20
 
21
+ # Set appropriate permissions for the application directory
22
+ RUN chown -R user:user /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/*
26
 
27
+ # Set the entrypoint script as executable
28
+ COPY entrypoint.sh /usr/local/bin/entrypoint.sh
29
+ RUN chmod +x /usr/local/bin/entrypoint.sh
30
 
31
+ # Switch to the user for improved security
32
  USER user
33
 
34
+ # Define the entrypoint script to handle user creation and application startup
35
+ ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
 
 
 
36
 
37
+ # Default command to run if the user doesn't provide a command
38
+ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--reload"]