Skip to content

Commit ccdd795

Browse files
committed
feat: clone access modules in docker-entrypoint
1 parent 737bfe5 commit ccdd795

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

docker-entrypoint.sh

+3
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,8 @@ mkdir -p /ebs/logs
1010
touch /ebs/logs/bstack.log
1111
tail -n 0 -f /ebs/logs/bstack.log &
1212

13+
# run scripts/clone_access_modules.py to clone access modules
14+
python scripts/clone_access_modules.py
15+
1316
echo Starting Django runserver.
1417
python manage.py runserver 0.0.0.0:8000

scripts/clone_access_modules.py

+20-3
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,29 @@
99
urls = config["access_modules"]["git_urls"]
1010
for url in urls:
1111
folder_name = url.split("/").pop()[:-4]
12+
folder_path = "./Access/access_modules/"+folder_name
1213
try:
13-
if os.path.exists("./Access/access_modules/"+folder_name):
14-
Repo("./Access/access_modules/"+folder_name).remotes.origin.pull()
14+
if os.path.exists(folder_path):
15+
Repo(folder_path).remotes.origin.pull()
1516
else:
16-
Repo.clone_from(url, "./Access/access_modules/"+folder_name)
17+
Repo.clone_from(url, folder_path)
18+
# move all folders, not files in the cloned repo to the access_modules folder except the .git, .github and secrets folder
19+
for file in os.listdir(folder_path):
20+
if os.path.isdir(folder_path+"/"+file) and file != ".git" and file != ".github" and file != "secrets":
21+
os.rename(folder_path+"/"+file, "./Access/access_modules/"+file)
22+
23+
# remove the cloned repo folder entirely with all its contents which includes folders and files
24+
for root, dirs, files in os.walk(folder_path, topdown=False):
25+
for file in files:
26+
os.remove(os.path.join(root, file))
27+
for dir in dirs:
28+
os.rmdir(os.path.join(root, dir))
29+
os.rmdir(folder_path)
30+
31+
print("Clonning successful!")
32+
1733
except Exception as e:
34+
print(e)
1835
print("failed cloning "+folder_name+".")
1936
except Exception as e:
2037
print("Access module cloning failed!")

0 commit comments

Comments
 (0)