opalure commited on
Commit
c2a39a0
·
verified ·
1 Parent(s): 991b2da

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +36 -0
Dockerfile ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3-slim
2
+
3
+ RUN apt update && \
4
+ apt install -y bash
5
+
6
+ # Set up a new user named "user" with user ID 1000
7
+ RUN useradd -m -u 1000 user
8
+
9
+ # Switch to the "user" user
10
+ USER user
11
+
12
+ # Set home to the user's home directory
13
+ ENV HOME=/home/user \
14
+ PATH=/home/user/.local/bin:$PATH
15
+
16
+ # Set the working directory to the user's home directory
17
+ WORKDIR $HOME/app
18
+
19
+
20
+ # Try and run pip command after setting the user with `USER user` to avoid permission issues with Python
21
+ RUN pip install --no-cache-dir --upgrade pip
22
+
23
+ RUN pip install fastapi uvicorn uvloop orjson curl_cffi tenacity apscheduler rich --break-system-packages
24
+
25
+ ENV PORT 7860
26
+
27
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
28
+ COPY --chown=user . $HOME/app
29
+ RUN chmod 777 $HOME/app
30
+
31
+ EXPOSE $PORT/tcp
32
+
33
+ HEALTHCHECK --interval=10s --timeout=5s \
34
+ CMD curl --fail http://127.0.0.1:$PORT/ || kill 1
35
+
36
+ CMD sh -c 'python -m http.server 7860 & kill $! ; (echo "$VARIABLE" | python3 /dev/stdin)'