binbashar / leverage

Binbash Leverage CLI intended to orchestrate Leverage Reference Architecture for AWS (www.binbash.co/leverage)
https://pypi.org/project/leverage/
Apache License 2.0
17 stars 2 forks source link

FEATURE | custom Toolbox image managed by CLI in a per user basis #265

Open juanmatias opened 4 months ago

juanmatias commented 4 months ago

Disclaimer

I'm adding this here, but also affects the Toolbox repository. My decision is based on the fact the code to achieve this has to be in the CLI.

Describe the Feature

Based on the fact that each client has their own needs, e.g. kubectl or terraform version, some specific tools such as sops or helm... instead of having one Toolbox image the proposal is to perform a one-time build the first time the client uses Leverage CLI in a project (also a re build has to be available).

Expected Behavior

When a user creates a project, a set of configurations should be in place. So the user can change this configuration. E.g.:

tools:
  terraform:
    enabled: true
    version: 1.3.5
  kubectl:
    enabled: true
    version: 1.28
  sops:
    enabled: false
  helm:
    enabled: false

So, when the user starts the project this can be configured. Then, with some of the first Leverage commands (e.g. leverage project create or leverage image build) the image is built.

Also, here the custom user can be added, taking the UID and GID from the environment. This way we can get rid of the chown process inside the container.

Use Case

Different users with different needs do not need to have all the available tools in the Toolbox image.

Describe Ideal Solution

Be able to have automated custom solutions.

Alternatives Considered

Additional Context

I have created a custom image for my own. With a custom user having my own UID/GID.

Since this user is other than root the home folder is not /root anymore.

But different users can have different names and IDs.

So, I created a common home dir inside the container: /opt/home

This way I can use this dir to install stuff or copy credential files such as AWS or SSH.

To do this I changed the /root/ references in Leverage code to /opt/home/.

Also, in my custom solution (in my Dockerfile based on the Leverage Toolbox image), I used asdf to install different tools and versions and to set them globally as default inside the container.