Spaces:
Sleeping
Sleeping
Commit
·
aa54a94
1
Parent(s):
2bd12b8
Update Dockerfile
Browse files- Dockerfile +17 -22
Dockerfile
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
-
# Use
|
| 2 |
-
FROM circulartextapp/spaceread
|
| 3 |
|
| 4 |
# Set the working directory to /app
|
| 5 |
WORKDIR /app
|
|
@@ -7,39 +7,34 @@ WORKDIR /app
|
|
| 7 |
# Copy the current directory contents into the container at /app
|
| 8 |
COPY . /app
|
| 9 |
|
| 10 |
-
# Define the
|
| 11 |
-
ARG
|
| 12 |
-
ENV
|
| 13 |
|
| 14 |
# Check if the user already exists
|
| 15 |
-
RUN if
|
| 16 |
-
echo "User
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
else \
|
| 18 |
-
useradd -m -u
|
| 19 |
fi
|
| 20 |
|
| 21 |
# Set appropriate permissions for the application directory
|
| 22 |
-
RUN chown -R
|
| 23 |
|
| 24 |
-
#
|
| 25 |
-
USER "$USERNAME"
|
| 26 |
-
|
| 27 |
-
# Intermediate image with additional packages
|
| 28 |
-
FROM debian:bullseye-slim as packages
|
| 29 |
-
|
| 30 |
-
# Install gosu using apt-get
|
| 31 |
RUN apt-get update && apt-get install -y gosu && rm -rf /var/lib/apt/lists/*
|
| 32 |
|
| 33 |
-
# Final image
|
| 34 |
-
FROM base
|
| 35 |
-
|
| 36 |
-
# Copy gosu from the packages image
|
| 37 |
-
COPY --from=packages /usr/sbin/gosu /usr/sbin/gosu
|
| 38 |
-
|
| 39 |
# Set the entrypoint script as executable
|
| 40 |
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
| 41 |
RUN chmod +x /usr/local/bin/entrypoint.sh
|
| 42 |
|
|
|
|
|
|
|
|
|
|
| 43 |
# Define the entrypoint script to handle user creation and application startup
|
| 44 |
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
| 45 |
|
|
|
|
| 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 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 [ -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 |
|