gperdomor / nx-tools

Nx Workspaces builders and tools
MIT License
360 stars 56 forks source link

Is it possible to use typerefs as build args? #1155

Open rudfoss-rr opened 3 weeks ago

rudfoss-rr commented 3 weeks ago

I have several targets that build containers in my project and some depend on each other. I can use the tags option to specify that the containers will be tagged with the branch name which is great when building in a feature branch, but is there a way to use the same value in the build-args to tie multiple container images from the same branch together?

Something like this:

project.json:

{
    "executor": "@nx-tools/nx-container:build",
    "dependsOn": [
        {
            "projects": "@project/source",
            "target": "prebuild"
        }
    ],
    "options": {
        "build-args": ["BASE_BUILD_TAG='type=ref,event=pr'"],
        "metadata": {
            "images": ["test-project"],
            "load": true,
            "tags": ["type=schedule", "type=ref,event=branch", "type=ref,event=tag", "type=ref,event=pr"]
        }
    }
}

Dockerfile:

ARG BASE_BUILD_TAG=latest
FROM base-build:$BASE_BUILD_TAG AS buildbase

Or am I going about this the wrong way maybe? I'm still relatively new to containers.