This commit is contained in:
Egor Matveev 2021-11-13 18:05:37 +03:00
parent 7ecc725dbb
commit 8b772f25bb
2 changed files with 5 additions and 3 deletions

View File

@ -56,7 +56,9 @@ class BaseTester:
self.solution = solution self.solution = solution
def execute(self): def execute(self):
mkdir(str(self.solution.id)) if not exists("solutions"):
mkdir("solutions")
mkdir("solutions/" + str(self.solution.id))
for file in SolutionFile.objects.filter(solution=self.solution): for file in SolutionFile.objects.filter(solution=self.solution):
dirs = file.path.split('/') dirs = file.path.split('/')
for i in range(len(dirs) - 1): for i in range(len(dirs) - 1):
@ -67,7 +69,7 @@ class BaseTester:
fs.write(get_bytes(file.fs_id)) fs.write(get_bytes(file.fs_id))
self.solution.result = CONSTS["testing_status"] self.solution.result = CONSTS["testing_status"]
self.solution.save() self.solution.save()
docker_command = f"docker run --name solution_{self.solution.id} --volume=/sprint-data/worker/{self.solution.id}:/{self.working_directory} -t -d {self.solution.language.image}" docker_command = f"docker run --name solution_{self.solution.id} --volume=/sprint-data/solutions/{self.solution.id}:/{self.working_directory} -t -d {self.solution.language.image}"
print(docker_command) print(docker_command)
call(docker_command, shell=True) call(docker_command, shell=True)
print("Container created") print("Container created")

View File

@ -74,5 +74,5 @@ services:
- postgres - postgres
- storage - storage
volumes: volumes:
- /sprint-data/worker:/usr/src/app - /sprint-data/solutions:/usr/src/app/solutions
- /var/run/docker.sock:/var/run/docker.sock - /var/run/docker.sock:/var/run/docker.sock