Spaces:
Sleeping
Sleeping
circulartext
commited on
Commit
·
80ea05b
1
Parent(s):
515810c
Update Dockerfile
Browse files- Dockerfile +2 -29
Dockerfile
CHANGED
@@ -1,6 +1,4 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
# Use a suitable base Docker image with necessary dependencies
|
4 |
FROM circulartextapp/spaceread
|
5 |
|
6 |
# Set the working directory to /app
|
@@ -9,24 +7,6 @@ WORKDIR /app
|
|
9 |
# Copy the current directory contents into the container at /app
|
10 |
COPY . /app
|
11 |
|
12 |
-
# Define the user ID in the environment variable USER_ID with a default value
|
13 |
-
ARG USER_ID=1000
|
14 |
-
ENV USER_ID=$USER_ID
|
15 |
-
|
16 |
-
# Check if the user already exists
|
17 |
-
RUN if [ -z "$USER_ID" ]; then \
|
18 |
-
echo "User ID not provided. Using the default user ID 1000."; \
|
19 |
-
USER_ID=1000; \
|
20 |
-
fi && \
|
21 |
-
if id "$USER_ID" >/dev/null 2>&1; then \
|
22 |
-
echo "User with ID $USER_ID already exists."; \
|
23 |
-
else \
|
24 |
-
useradd -m -u "$USER_ID" user; \
|
25 |
-
fi
|
26 |
-
|
27 |
-
# Set appropriate permissions for the application directory
|
28 |
-
RUN chown -R user:user /app && chmod -R 755 /app
|
29 |
-
|
30 |
# Install gosu (adjust the package manager based on your base image)
|
31 |
RUN apt-get update && apt-get install -y gosu && rm -rf /var/lib/apt/lists/*
|
32 |
|
@@ -34,12 +14,5 @@ RUN apt-get update && apt-get install -y gosu && rm -rf /var/lib/apt/lists/*
|
|
34 |
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
35 |
RUN chmod +x /usr/local/bin/entrypoint.sh
|
36 |
|
37 |
-
# Switch to the user for improved security
|
38 |
-
USER user
|
39 |
-
|
40 |
-
# Define the entrypoint script to handle user creation and application startup
|
41 |
-
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
42 |
-
|
43 |
# Default command to run if the user doesn't provide a command
|
44 |
-
CMD ["
|
45 |
-
|
|
|
1 |
+
# Use the spaceread base Docker image
|
|
|
|
|
2 |
FROM circulartextapp/spaceread
|
3 |
|
4 |
# Set the working directory to /app
|
|
|
7 |
# Copy the current directory contents into the container at /app
|
8 |
COPY . /app
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
# Install gosu (adjust the package manager based on your base image)
|
11 |
RUN apt-get update && apt-get install -y gosu && rm -rf /var/lib/apt/lists/*
|
12 |
|
|
|
14 |
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
15 |
RUN chmod +x /usr/local/bin/entrypoint.sh
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
# Default command to run if the user doesn't provide a command
|
18 |
+
CMD ["/usr/local/bin/entrypoint.sh", "${USERNAME:-default_user}"]
|
|