File size: 1,378 Bytes
9fcdba0
74b6dad
77bb5ac
484cf90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77bb5ac
 
484cf90
 
77bb5ac
8a74a9b
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Use your base Docker image from Docker Hub
FROM circulartextapp/circulartextai

# Set the working directory to /app
WORKDIR /app

# Copy the current directory contents into the container at /app
COPY . /app

# Define the user ID in the environment variable USER_ID with a default value
ARG USER_ID=1000
ENV USER_ID=$USER_ID

# Check if the user already exists
RUN if [ -z "$USER_ID" ]; then \
      echo "User ID not provided. Using the default user ID 1000."; \
      USER_ID=1000; \
    fi && \
    if id "$USER_ID" >/dev/null 2>&1; then \
      echo "User with ID $USER_ID already exists."; \
    else \
      adduser --uid "$USER_ID" --disabled-password --gecos '' appuser; \
    fi

# Set appropriate permissions for the application directory
RUN chown -R appuser:appuser /app && chmod -R 755 /app

# Install gosu (adjust the package manager based on your base image)
RUN apt-get update && apt-get install -y gosu && rm -rf /var/lib/apt/lists/*

# Set the entrypoint script as executable
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh

# Switch to the user for improved security
USER appuser

# Define the entrypoint script to handle user creation and application startup
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

# Specify the command to run your application
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]