Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions simoc-web.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def docker_run(*args):
# detect and connect to the network if it's available
net_name = 'simoc_simoc-net'
cp = subprocess.run(['docker', 'network', 'inspect', net_name],
capture_output=True)
stdout=subprocess.DEVNULL)
net_args = ['--network', net_name] if cp.returncode == 0 else []
fe_branch = f'VITE_FE_BRANCH={get_current_branch(SIMOC_WEB_DIR)}'
be_branch = f'VITE_BE_BRANCH={get_current_branch(SIMOC_DIR)}'
Expand Down Expand Up @@ -108,22 +108,28 @@ def build():
return docker_run('-it', '--entrypoint', 'npm', IMGNAME, 'run', 'build')

@cmd
def copy_dist_dir():
def copy_dist_dir(assume_yes=False):
"""Copy the dist dir into the "simoc" repo."""
# assume that both the simoc and simoc-web repos are in the same dir
simoc_server_dir = SIMOC_DIR / 'simoc_server'
simoc_web_dist_dir = SIMOC_WEB_DIR / 'dist'
if not simoc_server_dir.exists():
print(f'* <{simoc_server_dir}> does not exist')
if not assume_yes:
return False
p = input('* Please enter the path to the "simoc_server" dir: ')
simoc_server_dir = pathlib.Path(p).resolve()
ans = input(f'* Copy <{simoc_web_dist_dir}> into <{simoc_server_dir}>? [Y/n] ')
ans = 'y'
if not assume_yes:
ans = input(f'* Copy <{simoc_web_dist_dir}> into <{simoc_server_dir}>? [Y/n] ')
if ans.lower().strip() == 'n':
print(f'* <{simoc_web_dist_dir}> not copied')
return False
simoc_dist_dir = simoc_server_dir / 'dist'
if simoc_dist_dir.exists():
ans = input(f'* <{simoc_dist_dir}> already exist, remove it? [Y/n] ')
ans = 'y'
if not assume_yes:
ans = input(f'* <{simoc_dist_dir}> already exist, remove it? [Y/n] ')
if ans.lower().strip() == 'n':
print(f'* <{simoc_web_dist_dir}> not copied')
return False
Expand All @@ -144,6 +150,12 @@ def setup():
return (install_docker() and build_image() and setup_deps() and
build_and_copy())

@cmd
def deploy():
"""Build the SIMOC frontend and copy it for deployment."""
return (build_image() and setup_deps() and build() and
copy_dist_dir(assume_yes=True))


def create_help(cmds):
help = ['Full list of available commands:']
Expand Down