circulartext commited on
Commit
ed9b501
·
1 Parent(s): 3f0e6c7

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +24 -41
Dockerfile CHANGED
@@ -1,54 +1,37 @@
1
- # Use the base Docker image with necessary dependencies
2
- FROM circulartextapp/spaceread as base
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 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 build tools
25
- RUN mkdir -p /var/lib/apt/lists/partial && \
26
- chmod 744 /var/lib/apt/lists && \
27
- chmod 755 /var/lib/apt/lists/partial && \
28
- apt-get update && apt-get install -y build-essential
29
-
30
- # Switch to the user for improved security
31
- USER user
32
 
33
- # Intermediate image with additional packages
34
- FROM debian:bullseye-slim as packages
35
 
36
- # Install gosu using apt-get
37
- RUN apt-get update && apt-get install -y gosu && rm -rf /var/lib/apt/lists/*
38
 
39
- # Final image
40
- FROM base
41
 
42
- # Copy gosu from the packages image
43
- COPY --from=packages /usr/sbin/gosu /usr/sbin/gosu
44
 
45
- # Set the entrypoint script as executable
46
- COPY entrypoint.sh /usr/local/bin/entrypoint.sh
47
- RUN sudo chmod +x /usr/local/bin/entrypoint.sh
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"]
54
 
 
1
+ FROM circulartextapp/lastread
 
2
 
3
+ # Define environment variables for user identification and configuration
4
+ ENV USER_ID=""
5
+ ENV USER_CONFIG=""
6
 
7
+ # Install Hugging Face dependencies
8
+ RUN pip install transformers datasets huggingface_hub
9
 
10
+ # Define additional user group for the application
11
+ RUN addgroup --system myappgroup
 
 
 
 
 
 
 
 
 
 
 
12
 
13
+ # Add user with unique identifier and assign to the group
14
+ ARG USER_ID=1000
15
+ RUN adduser --system --group myappuser --uid ${USER_ID} user
 
 
 
 
 
16
 
17
+ # Set the working directory to /app
18
+ WORKDIR /app
19
 
20
+ # Copy the current directory contents into the container at /app
21
+ COPY . .
22
 
23
+ # Set appropriate permissions for the application directory
24
+ RUN chown -R user:myappgroup /app && chmod -R 775 /app
25
 
26
+ # Set environment variable for user configuration file (optional)
27
+ COPY user_config.json .
28
 
29
+ # Entrypoint script to personalize the environment and run the application
30
+ ENTRYPOINT ["/app/entrypoint.sh"]
 
31
 
32
+ # Expose Hugging Face space port (e.g., 7860)
33
+ EXPOSE 7860
34
 
35
+ # Example CMD for Hugging Face Space application (modify as needed)
36
  CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--reload"]
37