Search code examples
google-app-engineterraformartifactorygoogle-cloud-build

How to use a docker image from Artifactory on Google App Engine?


How to deploy a docker image from Artifactory on Google App Engine?

What I am trying to achieve is deploying my docker image that is stored on a jfrog Artifactory to a Good App Engine. Though all the examples I find are pushing the image to Artifact Registry which is redundant as I only want to store the artifact on jfrog. Has anyone tried to do it before? Here is the further I could go using Cloud Build:

  - name: 'gcr.io/cloud-builders/docker'
    dir: /workspace/app
    args: [ 'pull', 'myjfrogurl.jfrog.io/$PROJECT_ID:$BRANCH_NAME' ]
  

Then I use terraform later to deploy:

resource "google_app_engine_flexible_app_version" "app_deploy" {

  version_id = "v1"
  service    = var.service_name
  runtime    = "nodejs"

   ... 

  deployment {

    container {
      # Here is the problem as it needs to be a google URI
      image = "myjfrogurl.jfrog.io/${var.project_id}:${var.branch_name}"
    }
  }

Maybe there is a way of doing that, it doesn't need to be via terraform or cloud build.

Edit With the following code is possible to pull the image from jfrog and push to Container Registry where it will be visible for App Engine or Cloud Run, though as the answer says it is not possible to keep the image stored in only one place

  # Pull from external repository
  - name: 'gcr.io/cloud-builders/docker'
    args: [ 'pull', 'myjfrogurl.jfrog.io/$PROJECT_ID:$BRANCH_NAME' ]

  # Do a fast build using --cache-from
  - name: 'gcr.io/cloud-builders/docker'
    args: [ 'build',
            '-t', 'gcr.io/$PROJECT_ID/appName:$BRANCH_NAME',
            '--cache-from', 'gcr.io/$PROJECT_ID/appName:$BRANCH_NAME',
            '.' ]
            
  # Tag the image for Container Registry
  - name: 'gcr.io/cloud-builders/docker'
    args: ['tag',
           'gcr.io/$PROJECT_ID/appName:$BRANCH_NAME']

  # Push to the Container Registry
  - name: 'gcr.io/cloud-builders/docker'
    args: ['push',  'gcr.io/$PROJECT_ID/appName:$BRANCH_NAME']

Solution

  • Posting Guillaume Blaquiere's comment as a Community Wiki answer for better visibility for the community:

    This is not possible for App Engine, and there is the same limitation with Cloud Run.

    To deploy an image to the App Engine it requires to push the image to the Google Container Registry. Under the hood container registry is a GCP bucket called eu.artifacts.projectId.appspot.com or artifacts.projectId.appspot.com (according to the region - more). Artifacty Registry is a service under the Container Registry to help managing the images.