Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

generic::invalid_argument: invalid build: invalid image name "us.gcr.io/.../... could not parse reference: us.gcr.io/..../

I'm trying to deploy a container automatically when I push to github, I enabled the functionality on GCP but it didn't work and it complains when triggered that :

generic::invalid_argument: invalid build: invalid image name "us.gcr.io/cifar-clf/CIFAR-10_classification/cifar-clf:f2d5c55fad600b733fc5bcc84550fdd9a325b05b": could not parse reference: us.gcr.io/cifar-clf/CIFAR-10_classification/cifar-clf:f2d5c55fad600b733fc5bcc84550fdd9a325b05b

Dockerfile(in the root of the project):

FROM python:3.8

ENV APP_HOME /app
WORKDIR $APP_HOME

COPY . ./

RUN pip install -r requirements.txt

EXPOSE 8080

CMD python app.py

but I got the error above.

For the ordinal deployement it works just fine using:

  • To submit a build using Google Cloud Build
gcloud builds submit --tag gcr.io/cifar-clf/cifar-clf --project=cifar-clf
  • To deploy the container
gcloud run deploy --image gcr.io/cifar-clf/cifar-clf --platform managed --project=cifar-clf --allow-unauthenticated

Any help or advice will be appreciated, Thanks folks!

like image 492
mhannani Avatar asked Oct 24 '25 02:10

mhannani


2 Answers

The named component of the image reference only allows for lowercase characters from the distribution implementation:

// alphaNumericRegexp defines the alpha numeric atom, typically a
// component of names. This only allows lower case characters and digits.
alphaNumericRegexp = match(`[a-z0-9]+`)

// separatorRegexp defines the separators allowed to be embedded in name
// components. This allow one period, one or two underscore and multiple
// dashes. Repeated dashes and underscores are intentionally treated
// differently. In order to support valid hostnames as name components,
// supporting repeated dash was added. Additionally double underscore is
// now allowed as a separator to loosen the restriction for previously
// supported names.
separatorRegexp = match(`(?:[._]|__|[-]*)`)

// nameComponentRegexp restricts registry path component names to start
// with at least one letter or number, with following parts able to be
// separated by one period, one or two underscore and multiple dashes.
nameComponentRegexp = expression(
    alphaNumericRegexp,
    optional(repeated(separatorRegexp, alphaNumericRegexp)))

So you should change:

us.gcr.io/cifar-clf/CIFAR-10_classification/cifar-clf:f2d5c55fad600b733fc5bcc84550fdd9a325b05b

to:

us.gcr.io/cifar-clf/cifar-10_classification/cifar-clf:f2d5c55fad600b733fc5bcc84550fdd9a325b05b
like image 78
BMitch Avatar answered Oct 25 '25 16:10

BMitch


The following approach will help you fix the error you are facing.

The same error occurred to me while deploying through cloudbuild.yaml using Build Triggers. enter image description here

You can override the value of your reponame using the variable $REPO_NAME as mentioned here

To resolve the error you got like I did,

  • Edit the Trigger
  • add the variable REPO_NAME and override the repo name with cifar-10_classification

P

The credit goes to https://stackoverflow.com/users/596285/bmitch for finding the root cause, as I stumble upon bmitch's root cause explanantion while doing this POC.

like image 28
navule Avatar answered Oct 25 '25 16:10

navule