Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.

If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!

[BM] How to build a docker container from gitlab using env file



  • Hi guys,

    I am looking for some help. I am trying to build a container using BM, and can't figure out how to pass env file to docker build

    I am using a simple git repo which contains:

    • Dockerfile
    • myapp.env

    How to config Docker::Build-Image to use myapp.env

    I am using a very simple script :

    Git::Checkout-Code();
    Docker::Build-Image();
    

    Any advice or sample is welcome


  • inedo-engineer

    Hi @philippe-camelio_3885,

    Based on that script, as long as your Dockerfile is at the root of the $WorkingDirectory (From defaults to $WorkingDirectory) and the myapp.env is specified within the Dockerfile, that script should work. Can you please tell me what you are seeing while running Build-Image?

    Thanks,
    Rich



  • Hi @rhessinger
    I will dig in this direction.
    I let you know.

    Thanks for the tip.
    Best regards



  • I finally found how to handle properly (I guess) the variable
    The Dockerfile looks like:

    ARG SOME_VAR=default_var
    
    FROM some_image:some_version
    
    WORKDIR /usr/src/app
    RUN ....
    
    

    and the Deploy script like :

    Git::Checkout-Code();
    Docker::Build-Image
    (
        DockerfileVariables: %(SOME_VAR:myvar),
        Tag: $ReleaseNumber-pre.$BuildNumber,
        RemoveAfterPush: true
    );
    

    bur I have signing problem to push container in proget. => I start a new thread



Inedo Website HomeSupport HomeCode of ConductForums GuideDocumentation