Eslam-Magdy commited on
Commit
71cd92c
·
verified ·
1 Parent(s): c558e9c

Upload 2 files

Browse files
Files changed (2) hide show
  1. Dockerfile +22 -0
  2. main.py +44 -0
Dockerfile ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9
2
+
3
+ RUN useradd -m -u 1000 user
4
+
5
+ WORKDIR /code
6
+
7
+ COPY ./requirements.txt /code/requirements.txt
8
+
9
+ USER root
10
+ RUN chown -R user:user /code
11
+
12
+ USER user
13
+
14
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
15
+
16
+ RUN pip show uvicorn
17
+
18
+ COPY --chown=user:user . /code
19
+
20
+ ENV PATH="/home/user/.local/bin:${PATH}"
21
+
22
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
main.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import time
3
+ import shutil
4
+ import subprocess
5
+
6
+ # command = ["pip", "install", "flet==0.23.2"]
7
+
8
+ # subprocess.run(command, check=True)
9
+
10
+ # command = ["pip", "install", "flet-fastapi==0.19.0", "--no-deps"]
11
+
12
+ # subprocess.run(command, check=True)
13
+
14
+
15
+ gh_token = os.getenv("gh_token")
16
+
17
+ url_with_token = f"https://{gh_token}@github.com/Eslam-Magdy-1297/Netways-AIJudge.git"
18
+
19
+ os.system(f"git clone {url_with_token}")
20
+
21
+ time.sleep(10)
22
+
23
+ source_dir = "Netways-AIJudge/backend"
24
+ destination_dir = "."
25
+
26
+ import os
27
+
28
+ current_directory = os.getcwd()
29
+
30
+ items = os.listdir(current_directory)
31
+
32
+ for item in items:
33
+ print(item)
34
+
35
+ for item in os.listdir(source_dir):
36
+ s = os.path.join(source_dir, item)
37
+ d = os.path.join(destination_dir, item)
38
+ shutil.move(s, d)
39
+
40
+ os.rmdir(source_dir)
41
+
42
+ with open("index.py", "r") as file:
43
+ code = file.read()
44
+ exec(code)