Skip to main content

Render, merge and validate docker_compose files for deploying a stack

Project description

Stack Config

version number: 0.1.0 author: ScienceLogic

Overview

Render, merge and validate docker_compose files for deploying a stack.

This library is using docker-compose merging process, but at the end it does a final verification to let users know whether this is a valid docker-compose for deploying a stack or not, as docker-compose doesn't validate that.

Additionally, this library will compile valid yaml jinja2 templates, so they can be merged along with the other docker-compose files.

Installation

To install use pip:

$ pip install stackconfig

Or clone the repo:

$ git clone https://github.com/Sciencelogic/stackconfig.git
$ python setup.py install

Development

  1. Fork
  2. Set Dev Environment
pip install -r dev_requirements.txt
pip install -r requirements.txt
pip install -e .
git checkout -b feature-more-cool-stuff

Test

# run tests using tox
tox
# run tests with pytest
pytest

Version

bumpversion major  # major release
or
bumpversion minor  # minor release
or
bumpversion patch  # hotfix release

git push origin release-n.n.0
or
git push origin hotfix-x.x.n

Usage example as cli tool

$ stackconfig --help
Usage: stackconfig [OPTIONS]

Options:
  -f, --file PATH        docker-compose file to be merged. Accept multiple
                         arguments.
  -o, --output PATH      Output path for the final docker-compose file
                         [default: /tmp/docker-compose-20220425-16-49-16.yml]
  -d, --j2data PATH      Yaml file that contains variables to render the
                         provided jinja2 template.
  -t, --j2template PATH  Jinja2 template that needs to be a valid docker-
                         compose file after being rendered.
  --version TEXT         Set valid version for the final docker-compose file
  --help                 Show this message and exit.
$ stackconfig -f docker-compose.yml -f compose-override.yml -t docker-compose-template.yml.j2 -d data_file.yml --version 3.8 -o docker-compose-final.yml

Usage example using Python

from stackconfig.stackconfig import StackConfigCompose
from stackconfig.utils.jinja2_utils import render_jijnja2_compose

jinja_env = {}
yml_compiled_files = render_jijnja2_compose(['/tmp/docker-compose.yml.j2',
                                             '/tmp/docker-compose-override-yml.j2'],
                                            data_file='/tmp/data_file.yml',
                                            data_dict=jinja_env)
# valid docker-compose files can be appended, all of them are going to be merged using the docker-compose library
yml_compiled_files.append("/tmp/docker-copmose-override2.yml")
stack_config = StackConfigCompose(yml_compiled_files, '/tmp/docker-compose-output.yml')
stack_config.merge_stack_compose()

Not Exactly What You Want?

Options that may be a good fit for you:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stackconfig-1.0.1.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

stackconfig-1.0.1-py2.py3-none-any.whl (7.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file stackconfig-1.0.1.tar.gz.

File metadata

  • Download URL: stackconfig-1.0.1.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.13

File hashes

Hashes for stackconfig-1.0.1.tar.gz
Algorithm Hash digest
SHA256 ad88070187454cac5aa79dea9928063e78e2d95d33eb6ca5685980d51447f59e
MD5 336998daa46406d36eef44b4f0dd99f3
BLAKE2b-256 dfd92b2573bc1f03cf72bd3e4a310a0f2600cb83d1db5fea1178b523b1063d9b

See more details on using hashes here.

File details

Details for the file stackconfig-1.0.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for stackconfig-1.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e86a4c7510bcda4f0d4143ce9fcb53a10608f6b719903961f30d54e225673ffb
MD5 4aa63f34ea91ac22bfca44da14c7410d
BLAKE2b-256 f755f35a83606a1d6f454cdde128cadc282df06ceb466d1720781e425fb2620d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page