- Python 3
- Python packages
- Rename setup.py to setup
chmod +x setup./setup up- Once done with project services setup, then teardown services
./setup down
chmod +x setup./setup up./setup down| #!/usr/bin/env python3 | |
| from pathlib import Path | |
| import hashlib | |
| import os | |
| import fire | |
| import portpicker | |
| def get_name(): | |
| folder = Path(__file__).resolve() | |
| h = hashlib.sha256(bytes(folder)) | |
| hash_part = h.hexdigest()[:6] | |
| return f"{folder.parent.name}-{hash_part}" | |
| class Cli: | |
| def __init__(self): | |
| self.container_name = get_name() | |
| self.mysql_path = Path(__file__).resolve().parent/'.mysql' | |
| self.init_path = self.mysql_path/'initdb.d' | |
| self.data_path = self.mysql_path/'data' | |
| def up(self): | |
| """Start MySQL Server Container""" | |
| port = portpicker.pick_unused_port() | |
| print(f'MySQL Port possibility {port}, but sticking to 3306') | |
| print(f'''podman run --name {self.container_name} -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=spark --publish 3306:3306 --publish {port}:3306 --volume {self.init_path}:/docker-entrypoint-initdb.d:Z --volume {self.data_path}:/var/lib/mysql:Z --security-opt label=disable --detach percona:5.6 --lower_case_table_names=1''') | |
| def down(self): | |
| print(f'podman rm -f {self.container_name}') | |
| def logs(self): | |
| print(f'podman logs -f {self.container_name}') | |
| def clean(self): | |
| print(f'sudo rm -rf {self.data_path}') | |
| if __name__ == "__main__": | |
| fire.Fire(Cli()) |