Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On the build command, allow use the variable to render the images #38

Open
apenella opened this issue May 6, 2023 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@apenella
Copy link
Contributor

apenella commented May 6, 2023

At this moment, the image definitions are rendered in starting stages of Stevedore, then it is not possible to use the variables that are passed through the CLI when you render the image definition. Those variables are only available in the Dockerfile.

Imagine your applications are managed in a standardized way, and you can build all of the using only one Dockerfile and one image definition.

You have the following structure:

├── apps
│   ├── app1
│   │   └── app.sh
│   ├── app2
│   │   └── app.sh
│   └── app3
│       └── app.sh
├── build
│   └── Dockerfile

The apps folder contains your application's code. Since the images for those applications can be built in the same way, you get the most out of the feature that allows you to merge build context, therefore, you define a Dockerfile in the build folder which can be used to build the image for any of those applications.

Owing that your applications are being managed in a standardized way, you should be able to have only one image definition, a definition like the following one:

images:
  app:
    "*":
      version: "{{ .Version }}-{{ .Parent.Name }}{{ .Parent.Version }}"
      registry: registry.stevedore.test
      vars:
        app_name: app1
      builder:
        driver: docker
        options:
          context:
            - path: "apps/{{ .Vars.app_name }}"
            - path: build
      parents:
        busybox:
          - "1.36"

As you can see in the build context you would need to use something like - path: "apps/{{ .Vars.app_name }}" which will allow you to choose the source of your application's code at build time, and choose the app_name when you build the image.

$ stevedore build app -v v1 -i app1 -x app_name=app1
$ stevedore build app -v v1 -i app2 -x app_name=app2
$ stevedore build app -v v1 -i app3 -x app_name=app2
@apenella apenella added the enhancement New feature or request label May 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant