-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add initial functionalities * Improve CI * Remove podman from the conda env file
- Loading branch information
Showing
12 changed files
with
2,885 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
version: 1.0.0 | ||
compose-app: docker-compose | ||
service-groups: | ||
- name: group1 | ||
project-name: project1 # optional | ||
compose-path: containers/tests/group1/compose.yaml | ||
env-file: .env | ||
services: | ||
default: service1,service3 | ||
list: | ||
- name: service1 | ||
health-check: true | ||
- name: service2 | ||
health-check: false | ||
- name: service3 | ||
health-check: true | ||
- name: group2 | ||
project-name: null # optional | ||
compose-path: containers/tests/group2/compose.yaml | ||
env-file: .env | ||
services: | ||
default: null | ||
list: | ||
- name: service1 | ||
health-check: true | ||
- name: service1 | ||
health-check: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"python.formatting.blackPath": "/home/xmn/mambaforge/envs/containers-sugar/bin/blue", | ||
"python.formatting.provider": "black" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,93 @@ | ||
# containers-sugar | ||
|
||
Simplify the usage of containers | ||
Simplify the usage of containers. | ||
|
||
You maybe would be thinking, why I need new library that wrap-up | ||
docker-compose or podman-compose if it is really simple to use? | ||
|
||
Yes, that is simple to use, but if you have some other parameters to | ||
the compose command line, it could be very tedious to right it every time | ||
such as `--env-file`, `--project-name`, `--file`, etc. | ||
|
||
So, in this case we could use something like a script or `make`, right? | ||
|
||
Yes, and just for one project it would be good enough. But, if you maintain | ||
or collaborate a bunch of projects, it would be like a boiler plate. | ||
|
||
Additionally, if you are maintaining some extra scripts in order to improve | ||
your containers stack, these scripts would be like a boilerplate as well. | ||
|
||
So, the idea of this project is to organize the containers stack and | ||
gather some useful scripts and keep this information centralized in a | ||
configuration file. So the command line would be very simple. | ||
|
||
|
||
* Free software: BSD 3 Clause | ||
* Documentation: https://containers-sugar.readthedocs.io. | ||
* Documentation: https://osl-incubator.github.io/containers-sugar | ||
|
||
|
||
## Features | ||
|
||
* TODO | ||
|
||
## Credits | ||
The commands availables now are: | ||
`help`, `version`, `build`, `down`, `get-ip`, | ||
`logs`, `logs-follow`, `pull`, `restart`, | ||
`start`, `stop`, `wait`. | ||
|
||
> Note: get-ip and wait were not implemented yet. | ||
|
||
## How to use it | ||
|
||
First you need to have in the root of your project the config file `.containers-sugar.yaml`. This is an example of a configuration file: | ||
|
||
```yaml | ||
version: 1.0.0 | ||
compose-app: docker-compose | ||
service-groups: | ||
- name: group1 | ||
project-name: project1 # optional | ||
compose-path: containers/tests/group1/compose.yaml | ||
env-file: .env | ||
services: | ||
default: service1,service3 | ||
list: | ||
- name: service1 | ||
health-check: true | ||
- name: service2 | ||
health-check: false | ||
- name: service3 | ||
health-check: true | ||
- name: group2 | ||
project-name: null # optional | ||
compose-path: containers/tests/group2/compose.yaml | ||
env-file: .env | ||
services: | ||
default: null | ||
list: | ||
- name: service1 | ||
health-check: true | ||
- name: service1 | ||
health-check: false | ||
``` | ||
Some examples of how to use it: | ||
* build the defaults services (service1,service3) for group1: | ||
`containers-sugar build --group group1` | ||
|
||
* build the all services (there is no default service defined) for group2: | ||
`containers-sugar build --group group2` | ||
|
||
* build all services (ignore default) for group1: | ||
`containers-sugar build --group group1 --service ""` | ||
|
||
* start the default services for group1: | ||
`containers-sugar start --group group1` | ||
|
||
* restart all services (ignore defaults) for group1: | ||
`containers-sugar restart --group group1 --service ""` | ||
|
||
This package was created with Cookiecutter and the `osl-incubator/cookiecutter-python` project template. | ||
* restart service1 and service2 for group1: | ||
`containers-sugar restart --group group1 --service service1,service2` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
version: '3.4' | ||
|
||
services: | ||
service1: | ||
hostname: service1 | ||
image: python:latest | ||
ports: | ||
- 18000:8000 | ||
command: python -m http.server | ||
|
||
service2: | ||
hostname: service2 | ||
image: python:latest | ||
ports: | ||
- 18001:8000 | ||
command: python -m http.server | ||
|
||
service3: | ||
hostname: service2 | ||
image: python:latest | ||
ports: | ||
- 18002:8000 | ||
command: python -m http.server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
version: '3.4' | ||
|
||
services: | ||
service1: | ||
hostname: service1 | ||
image: python:latest | ||
ports: | ||
- 28000:8000 | ||
command: python -m http.server | ||
|
||
service2: | ||
hostname: service2 | ||
image: python:latest | ||
ports: | ||
- 28001:8000 | ||
command: python -m http.server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import argparse | ||
import os | ||
from pathlib import Path | ||
|
||
from containers_sugar import __version__, Sugar | ||
|
||
|
||
def _get_args(): | ||
parser = argparse.ArgumentParser( | ||
prog='Containers-Sugar', | ||
description=( | ||
'Containers-Sugar is a tool that help you to organize' | ||
"and simplify your containers' stack" | ||
), | ||
epilog=( | ||
'If you have any problem, open an issue at: ' | ||
'https://github.com/osl-incubator/containers-sugar' | ||
), | ||
) | ||
|
||
parser.add_argument( | ||
'action', | ||
choices=['help', 'version'] + Sugar.ACTIONS, | ||
help='Specify the command to be performed.', | ||
) | ||
parser.add_argument( | ||
'--service-group', '--group', | ||
dest="service_group", | ||
type=str, | ||
help='Specify the group name of the services you want to use', | ||
) | ||
parser.add_argument( | ||
'--services', | ||
type=str, | ||
help=( | ||
'Set the services for the container call. ' | ||
"Use comma to separate the services's name" | ||
), | ||
) | ||
parser.add_argument( | ||
'--config-file', | ||
type=str, | ||
default=str(Path(os.getcwd()) / '.containers-sugar.yaml'), | ||
help='Specify a custom location for the config file.', | ||
) | ||
return parser | ||
|
||
|
||
def show_version(): | ||
print(__version__) | ||
|
||
|
||
def app(): | ||
args_parser = _get_args() | ||
args = args_parser.parse_args() | ||
|
||
if args.action == 'help': | ||
return args_parser.print_help() | ||
|
||
if args.action == 'version': | ||
return show_version() | ||
|
||
sugar = Sugar(args) | ||
return sugar.run() | ||
|
||
|
||
if __name__ == '__main__': | ||
app() |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.