circulartext commited on
Commit
138fa67
·
1 Parent(s): 9c72c01

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +5 -51
Dockerfile CHANGED
@@ -1,53 +1,7 @@
1
- FROM circulartextapp/spaceread
2
 
3
- # Set the working directory to /app
4
- WORKDIR /app
5
 
6
- # Copy the current directory contents into the container at /app
7
- COPY . /app
8
-
9
- # Set the user ID in the environment variable USER_ID with a default value
10
- ARG USER_ID=1000
11
- ENV USER_ID=$USER_ID
12
-
13
- # Set the user group in the environment variable USER_GROUP with a default value
14
- ARG USER_GROUP=appuser
15
- ENV USER_GROUP=$USER_GROUP
16
-
17
- # Create the user and group if they don't already exist
18
- RUN if [ -z "$USER_ID" ]; then \
19
- echo "User ID not provided. Using the default user ID 1000."; \
20
- USER_ID=1000; \
21
- fi && \
22
- if [ -z "$USER_GROUP" ]; then \
23
- echo "User group not provided. Using the default user group appuser."; \
24
- USER_GROUP=appuser; \
25
- fi && \
26
- if id "$USER_ID" >/dev/null 2>&1; then \
27
- echo "User with ID $USER_ID already exists."; \
28
- else \
29
- adduser --uid "$USER_ID" --disabled-password --gecos '' "$USER_GROUP"; \
30
- fi
31
-
32
- # Add the user to the sudo group
33
- RUN usermod -aG sudo appuser
34
-
35
- # Set appropriate permissions for the application directory
36
- RUN chown -R appuser:appuser /app && chmod -R 755 /app
37
- RUN chown -R appuser:appuser /tmp
38
-
39
- # Install gosu (adjust the package manager based on your base image)
40
- RUN apt-get update && apt-get install -y gosu && rm -rf /var/lib/apt/lists/*
41
-
42
- # Set the entrypoint script as executable
43
- COPY entrypoint.sh /usr/local/bin/entrypoint.sh
44
- RUN chmod +x /usr/local/bin/entrypoint.sh
45
-
46
- # Switch to the user for improved security
47
- USER appuser
48
-
49
- # Define the entrypoint script to handle user creation and application startup
50
- ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
51
-
52
- # Default command to run if the user doesn't provide a command
53
- CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--reload"]
 
1
+ FROM circulartextapp/spaceout
2
 
3
+ # Set the user ID to a unique value for each user
4
+ ENV USER_ID=$(id -u)
5
 
6
+ # Set the user group to a unique value for each user
7
+ ENV USER_GROUP=$(id -g)