forked from allenai/pawls
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsh
executable file
·29 lines (23 loc) · 909 Bytes
/
sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from argparse import ArgumentParser
from subprocess import check_call
from os import path
def start_shell():
"""
Starts a shell session in the target container.
"""
# TODO: We could parse these from the `docker-compose.yaml` file instead
# of hard-coding them, but for now this is easier.
services = [ 'api', 'ui', 'proxy' ]
arg_parser = ArgumentParser(
description='A utility that opens a shell session in the specified web application container.',
prog='sh')
arg_parser.add_argument('service', type=str, help='The service container',
choices=list(services))
args = arg_parser.parse_args()
check_call(
[ 'docker-compose', 'exec', '--user', 'root', args.service, '/bin/sh' ],
cwd=path.realpath(path.dirname(__file__)))
if __name__ == '__main__':
start_shell()