services: build clis
This commit is contained in:
parent
ce1c49dd6e
commit
dfe70229c1
28
services/tools/build_cli.sh
Executable file
28
services/tools/build_cli.sh
Executable file
@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
SOURCE_DIR="$(git rev-parse --show-toplevel)/services/tools/cli"
|
||||||
|
OUTPUT_DIR="$HOME/.local/bin"
|
||||||
|
|
||||||
|
mkdir -p "$OUTPUT_DIR"
|
||||||
|
|
||||||
|
SCRIPTS=(
|
||||||
|
"${SOURCE_DIR}/docker_service.py"
|
||||||
|
"${SOURCE_DIR}/create_hardlinks.py"
|
||||||
|
)
|
||||||
|
|
||||||
|
for script in "${SCRIPTS[@]}"; do
|
||||||
|
script_name=$(basename "$script" .py | tr '_' '-')
|
||||||
|
pyinstaller --onefile --distpath "${OUTPUT_DIR}" "${script}" --name "${script_name}"
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "Successfully built $script_name and distributed to $OUTPUT_DIR"
|
||||||
|
else
|
||||||
|
echo "Failed to build $script_name"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
rm -rf build/ dist/ *.spec
|
||||||
|
|
||||||
|
echo "Build and distribution process completed."
|
||||||
|
|
||||||
@ -16,6 +16,24 @@ defined in a services file. The services file can be supplied as an
|
|||||||
argument, with a default value of ../services.yaml.
|
argument, with a default value of ../services.yaml.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
COMPOSE_ACTIONS = [
|
||||||
|
"up",
|
||||||
|
"down",
|
||||||
|
"build",
|
||||||
|
"start",
|
||||||
|
"stop",
|
||||||
|
"restart",
|
||||||
|
"logs",
|
||||||
|
"exec",
|
||||||
|
"ps",
|
||||||
|
"config",
|
||||||
|
"scale",
|
||||||
|
"pull",
|
||||||
|
"push",
|
||||||
|
"rm",
|
||||||
|
"version"
|
||||||
|
]
|
||||||
|
|
||||||
class DockerServiceCLI(BaseCli):
|
class DockerServiceCLI(BaseCli):
|
||||||
|
|
||||||
def configure_args(self, parser: ArgumentParser):
|
def configure_args(self, parser: ArgumentParser):
|
||||||
@ -29,10 +47,18 @@ class DockerServiceCLI(BaseCli):
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-n',
|
'-n',
|
||||||
'--service-name',
|
'--service-name',
|
||||||
help='Name of the service to run (default: all)',
|
help='Name of the service to run (Possibly: all)',
|
||||||
required=True,
|
required=True,
|
||||||
type=str
|
type=str
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'-a',
|
||||||
|
'--action',
|
||||||
|
help='Compose action. default "up". Options: [' + ', '.join(COMPOSE_ACTIONS) + ']',
|
||||||
|
choices=COMPOSE_ACTIONS,
|
||||||
|
default=COMPOSE_ACTIONS[0],
|
||||||
|
type=str
|
||||||
|
)
|
||||||
|
|
||||||
def process_args(self, parser: ArgumentParser):
|
def process_args(self, parser: ArgumentParser):
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
@ -75,7 +101,8 @@ class DockerServiceCLI(BaseCli):
|
|||||||
if service.env_file:
|
if service.env_file:
|
||||||
command_str.append('--env-file')
|
command_str.append('--env-file')
|
||||||
command_str.append(f'{service.env_file}')
|
command_str.append(f'{service.env_file}')
|
||||||
command_str.append('up')
|
command_str.append(self.args.action)
|
||||||
|
if self.args.action == 'up':
|
||||||
command_str.append('--build')
|
command_str.append('--build')
|
||||||
command_str.append('-d')
|
command_str.append('-d')
|
||||||
self.info(f"Executing command: {' '.join(command_str)}")
|
self.info(f"Executing command: {' '.join(command_str)}")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user