Spaces:
Sleeping
Sleeping
circulartext
commited on
Commit
•
934aa4a
1
Parent(s):
074e5c4
Update Dockerfile
Browse files- Dockerfile +28 -7
Dockerfile
CHANGED
@@ -1,8 +1,5 @@
|
|
1 |
-
# Use
|
2 |
-
FROM circulartextapp/
|
3 |
-
|
4 |
-
# Set up a new user named "user" with user ID 1000
|
5 |
-
RUN useradd -m -u 1000 user
|
6 |
|
7 |
# Set the working directory to /app
|
8 |
WORKDIR /app
|
@@ -10,9 +7,33 @@ WORKDIR /app
|
|
10 |
# Copy the current directory contents into the container at /app
|
11 |
COPY . /app
|
12 |
|
13 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
USER user
|
15 |
|
16 |
-
#
|
|
|
|
|
|
|
17 |
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
18 |
|
|
|
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
|
|
|
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 apk add --no-cache gosu
|
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"]
|
39 |
|