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 hashes)

Uploaded Source

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