I am trying to use a docker build that pulls in containers from the GitHub container repository and adds them to the built docker image. This works on my MacBook from the command shell but when I try to run it in CodeFresh, the build fails. The failure logs show that a username cannot be found. My build shell command is
docker build --build-arg GIT_USERNAME=$GIT_USERNAME --build-arg GIT_PERSONAL_ACCESS_TOKEN=$GIT_PERSONAL_ACCESS_TOKEN .
The CodeFresh documentation states that the equivalent of --build-arg is accomplished in CF by defining them in the yaml file as build_arguments. Here is how I am doing this in my yaml file:
`build:
title: "Building Docker image"
type: "build"
image_name: “<“my image name>
working_directory: "${{clone}}"
tag: "ThisTag"
#tag: "${{CF_BRANCH_TAG_NORMALIZED}}"
dockerfile: "Dockerfile"
build_arguments:
- GIT_USERNAME=${{GIT_USERNAME}}
- GIT_PERSONAL_ACCESS_TOKEN=${{GIT_PERSONAL_ACCESS_TOKEN}}
stage: "build”`
With GIT_USERNAME and GIT_PERSONAL_ACCESS_TOKEN defined in the Variables section of the workflow.
My actual docker file looks a little like this:
`FROM ghcr.io/<my build environment container> AS build
WORKDIR /app
COPY . ./
ARG GIT_USERNAME
ARG GIT_PERSONAL_ACCESS_TOKEN
ENV GIT_USERNAME=$GIT_USERNAME
ENV GIT_PERSONAL_ACCESS_TOKEN=$GIT_PERSONAL_ACCESS_TOKEN
RUN <my test to ensure the environment is working correctly>
FROM ghcr.io/<my build and deploy container> as deploy-node
WORKDIR /app
COPY --from=build /app/out .
ENTRYPOINT [“<mytool>“, “<myexecutablefile>“]`
I am a loss as to why this works in my command shell but not here. Anything I’m overlooking? Is there a problem with GitHub containers?