Giter Club home page Giter Club logo

Comments (4)

nirradi avatar nirradi commented on August 29, 2024 1

from mbt.

buddhike avatar buddhike commented on August 29, 2024

Sounds like a reasonable feature request. You are on the right track with describe, however That still does not give you an easy way to identify deps of a given module.

Are you able to share a bit more about your use case?

Thanks

from mbt.

nirradi avatar nirradi commented on August 29, 2024

I'm using docker to build artifacts, the image name (artifact) can simply be image_name:${MBT_MODULE_VERSION}, that works fine.

for a simple example, module parrot depends on module birb. When I change something in birb then running mbt build will trigger a build command in birb and a docker image named birb:somelonghash is created

since I've correctly added birb as a dependency in the parraot/.mbt.yml - the docker builld command is run in the parrot directory. Ideally I want the docker to start my parrot build from the bird image
so parrot/Dockerfile needs to look something like this

FROM _birb_:somelonghash
RUN ...
CP ....

but clearly I can't hardcode the long hash into the file since I'll have to change that file each time I commit a change to birb, so I need to do something like

FROM _birb_:{CURRENT_BIRB_VERSION}

and instead of simply running docker-compose build as my build script, I need to write a bash script:

CURRENT_BIRB_VERSION=$(mbt describe branch $(git rev-parse --abbrev-ref HEAD) --json | jq ._birb_.Version | sed 's/"//g'
)

docker-compose build

If I had access to MBT_BIRB_VERSION as an evironment variable always, I could have left

name: _parrot_
build: 
  default:
    cmd: 'docker-compose'
    args: ['build']

instead of adding a ./build.sh script to each folder that prepares the environment variable from the mbt describe command.

from mbt.

buddhike avatar buddhike commented on August 29, 2024

Thanks for providing more context @nirradi.

You should be able to create the environment your build needs before you execute mbt build with templating capabilities. To do that, create a template to provision all module versions in the environment

{{- range $mod := .Modules -}}
export MBT_{{$mod.Name}}_VERSION="{{$mod.Version}}"
{{end}}

Then you run mbt apply command to produce a file that you can source before you run mbt build.
This would save you from writing wrapper script in each module directory.

e.g.

mbt apply commit <sha> --to .env.tmpl --out build/.env
#ensure build directory is listed in .gitignore file
source build/.env
mbt build commit <sha>

You might also be able to use the same templating technique to generate docker-compose file on the fly. However, without intimate knowledge about what your pipeline, I cannot think of exact steps 😉.

from mbt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.