Spaces:
Sleeping
Sleeping
circulartext
commited on
Commit
•
a0e93dc
1
Parent(s):
52cffaa
Update Dockerfile
Browse files- Dockerfile +9 -27
Dockerfile
CHANGED
@@ -1,42 +1,24 @@
|
|
1 |
-
# Use
|
2 |
FROM circulartextapp/spaceread
|
3 |
|
4 |
-
#
|
5 |
-
|
|
|
|
|
|
|
6 |
|
7 |
# Copy the current directory contents into the container at /app
|
8 |
COPY . /app
|
9 |
|
10 |
-
#
|
11 |
-
|
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 |
-
useradd -m -u "$USER_ID" user; \
|
23 |
-
fi
|
24 |
-
|
25 |
-
# Set appropriate permissions for the application directory
|
26 |
-
RUN chown -R user:user /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 user
|
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"]
|
|
|
1 |
+
# Use the circulartextapp/spaceread image as the base image
|
2 |
FROM circulartextapp/spaceread
|
3 |
|
4 |
+
# Create a new user for each space
|
5 |
+
RUN useradd -m -u 1000 user
|
6 |
+
|
7 |
+
# Switch to the new user
|
8 |
+
USER user
|
9 |
|
10 |
# Copy the current directory contents into the container at /app
|
11 |
COPY . /app
|
12 |
|
13 |
+
# Install dependencies
|
14 |
+
RUN pip install -r requirements.txt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
# Set the entrypoint script as executable
|
17 |
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
18 |
RUN chmod +x /usr/local/bin/entrypoint.sh
|
19 |
|
|
|
|
|
|
|
20 |
# Define the entrypoint script to handle user creation and application startup
|
21 |
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
22 |
|
23 |
# Default command to run if the user doesn't provide a command
|
24 |
+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--reload"]
|