Pavan178 commited on
Commit
e43215b
·
verified ·
1 Parent(s): 7822729

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +39 -0
Dockerfile ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Set the working directory
2
+ WORKDIR /app
3
+
4
+ # Copy the current directory contents into the container
5
+ COPY . /app
6
+
7
+ # Define the user ID
8
+ ARG USER_ID=1000
9
+ ENV USER_ID=$USER_ID
10
+
11
+ # Create a new user if it doesn't exist
12
+ RUN if [ -z "$USER_ID" ]; then \
13
+ echo "User ID not provided. Using the default user ID 1000."; \
14
+ USER_ID=1000; \
15
+ fi && \
16
+ if id "$USER_ID" >/dev/null 2>&1; then \
17
+ echo "User with ID $USER_ID already exists."; \
18
+ else \
19
+ adduser --uid "$USER_ID" --disabled-password --gecos '' appuser; \
20
+ fi
21
+
22
+ # Set permissions
23
+ RUN chown -R appuser:appuser /app && chmod -R 755 /app
24
+
25
+ # Install necessary tools
26
+ RUN apt-get update && apt-get install -y gosu && rm -rf /var/lib/apt/lists/*
27
+
28
+ # Set up the entrypoint script
29
+ COPY entrypoint.sh /usr/local/bin/entrypoint.sh
30
+ RUN chmod +x /usr/local/bin/entrypoint.sh
31
+
32
+ # Switch to the non-root user
33
+ USER appuser
34
+
35
+ # Define the entrypoint
36
+ ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
37
+
38
+ # Default command
39
+ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--reload"]