Spaces:
Sleeping
Sleeping
Commit
·
2cf44c4
1
Parent(s):
099bed4
Create Dockerfile
Browse files- Dockerfile +34 -0
Dockerfile
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Use the base Docker image
|
2 |
+
FROM circulartextapp/spaceread
|
3 |
+
|
4 |
+
# Set the working directory to /app
|
5 |
+
WORKDIR /app
|
6 |
+
|
7 |
+
# Copy the current directory contents into the container at /app
|
8 |
+
COPY . /app
|
9 |
+
|
10 |
+
# Set up a new user named "user" dynamically
|
11 |
+
RUN if id "user" >/dev/null 2>&1; then \
|
12 |
+
echo "User 'user' already exists."; \
|
13 |
+
else \
|
14 |
+
useradd -m user; \
|
15 |
+
fi
|
16 |
+
|
17 |
+
# Set appropriate permissions for the application directory
|
18 |
+
RUN chown -R user:user /app && chmod -R 755 /app
|
19 |
+
|
20 |
+
# Install gosu (adjust the package manager based on your base image)
|
21 |
+
RUN apt-get update && apt-get install -y gosu && rm -rf /var/lib/apt/lists/*
|
22 |
+
|
23 |
+
# Set the entrypoint script as executable
|
24 |
+
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
25 |
+
RUN chmod +x /usr/local/bin/entrypoint.sh
|
26 |
+
|
27 |
+
# Switch to the user for improved security
|
28 |
+
USER user
|
29 |
+
|
30 |
+
# Define the entrypoint script to handle user creation and application startup
|
31 |
+
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
32 |
+
|
33 |
+
# Default command to run if the user doesn't provide a command
|
34 |
+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--reload"]
|