Commit 5702a529 authored by Luca Braun's avatar Luca Braun

Merge remote-tracking branch 'origin/feature/dashboard' into feature/dashboard

parents d16ca034 a51448e8
......@@ -35,6 +35,23 @@ def get_dockerfile_paths_and_names() -> Dict[str, str]:
return command_args
def is_flutter_project(path: str) -> bool:
test_file_path = f"{path}/pubspec.yaml"
return os.path.exists(test_file_path)
class cd:
"""Context manager for changing the current working directory"""
def __init__(self, newPath):
self.newPath = os.path.expanduser(newPath)
def __enter__(self):
self.savedPath = os.getcwd()
os.chdir(self.newPath)
def __exit__(self, etype, value, traceback):
os.chdir(self.savedPath)
if __name__ == '__main__':
p_image_name = None
......@@ -60,26 +77,40 @@ if __name__ == '__main__':
path = command_arg['path']
image_name = f"{DOCKERHUB_REPO_OWNER}/{command_arg['name']}"
# copy Dockerfile into root dir to have access to modules folder
shutil.copy2(os.path.join(path, DOCKER_BUILD_NAME), ROOT)
if is_flutter_project(path):
with cd(path):
print(f"> flutter build web")
os.system(f"flutter build web")
# build then remove Dockerfile
exit_val = os.system(f"docker image build -t {image_name} {ROOT}")
os.remove(os.path.join(ROOT, DOCKER_BUILD_NAME))
print(f"> docker image build -t {image_name} {path}")
exit_val = os.system(f"docker image build -t {image_name} {path}")
res_str.append(f"{image_name} built with exit code {exit_val}")
if exit_val != 0:
error = exit_val
else:
print(f"> docker push {image_name}")
exit_val = os.system(f"docker push {image_name}")
else:
# copy Dockerfile into root dir to have access to modules folder
shutil.copy2(os.path.join(path, DOCKER_BUILD_NAME), ROOT)
if exit_val != 0:
error = exit_val
# build then remove Dockerfile
exit_val = os.system(f"docker image build -t {image_name} {ROOT}")
os.remove(os.path.join(ROOT, DOCKER_BUILD_NAME))
else:
# push created Docker image
exit_val = os.system(f"docker push {image_name}")
res_str.append(f"{image_name} built with exit code {exit_val}")
res_str.append(f"{image_name} pushed with exit code {exit_val}")
if exit_val != 0:
error = exit_val
else:
# push created Docker image
exit_val = os.system(f"docker push {image_name}")
res_str.append(f"{image_name} pushed with exit code {exit_val}")
if exit_val != 0:
error = exit_val
print(f"Found {len(command_args)} images")
for s in res_str:
print(s)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
2.0.1
\ No newline at end of file
FROM nginx:latest
EXPOSE 80
COPY ./src/dashboard/build/web/ /usr/share/nginx/html/
\ No newline at end of file
sdk.dir=C:\\Users\\Luca\\AppData\\Local\\Android\\sdk
flutter.sdk=C:\\Users\\Luca\\Documents\\flutter\\flutter_windows_1.22.5-stable\\flutter
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment