Skip to main content

Converts environment variables into cli arguments for easy maintainable docker entry point

Project description

Desription

Instead of maintain ugly and long entrypoint scripts to call your module with environment variables as arguments from your dockerfile, just add this elegant converting framework from environment variables to cli command line arguments.

Installation

pip install env2cli

Usage

Assume your old dockerfile looked like this

...
ENV POSITIONAL_ARG val
ENV SOME_PARAM value
ENV OTHER_PARAM valy

...

ENTRYPOINT python main.py ${POSITIONAL_ARG} -p ${SOME_PARAM} --other ${OTHER_PARAM} ...

Add new file, for example, entrypoint.py like this:

from main import main
from env2cli import *

argv = bulk_apply([
    Argument('POSITIONAL_ARG'),
    Argument('SOME_PARAM', '-p'),
    Argument('OTHER_PARAM', '--other')
])

main(argv)

And the new dockerfile should be looking like this:

ENV POSITIONAL_ARG val
ENV SOME_PARAM value
ENV OTHER_PARAM valy

...

ENTRYPOINT python entrypoint.py

Or even if your program isn’t python!

ENV POSITIONAL_ARG val
ENV SOME_PARAM value
ENV OTHER_PARAM valy

...

ENTRYPOINT ./myprog $(env2cli.py)
# instead ENTRYPOINT ./myprogram ${POSITIONAL_ARG} -p ${SOME_PARAM} --other ${OTHER_PARAM}

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

env2cli-0.1.0.tar.gz (2.8 kB view details)

Uploaded Source

File details

Details for the file env2cli-0.1.0.tar.gz.

File metadata

  • Download URL: env2cli-0.1.0.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5

File hashes

Hashes for env2cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 96867cfc8884e7b570b6c520198105e4f97cd06b48c132c1981fa4a82154248c
MD5 7d74465d77f13b9e68fd7e8d63ca62cd
BLAKE2b-256 b5289974355f830b30abef6a7d0828a998e32a6ef6b2d560cd2a650c12efe6c7

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