Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

Objective

You have a working Docker project and the source code is managed in a Git repository. The goal of the tutorial is to push a Docker image to the GCP Artifact Registry

This process will include:

  • cloning the application from a Git repository

  • building the Docker image

  • pushing the Docker image to the GCP Artifact Registry.

We will walk through each of the FlexDeploy items that will need to be created/configured to accomplish this goal and have the Docker image published to the GCP Artifact Registry in a very short amount of time.

Checklist

Checklist

Description

Docker Registry Address

GCP Artifact Registry address

Docker Registry User

Use "oauth2accesstoken" to push images against the GCP Artifact Registry

Docker Registry Token/Password

Key file content, generated using Service Account of GCP

Docker Registry User Permission

Service account must have permission to push images to the GCP Artifact Registry

Configure Cloud-Specific credential

To configure credential details according to the cloud provider, please refer to this document: Docker Registry Setup For Cloud Providers

Configure Container Account

Configure GCP container account under Topology. FlexDeploy will use this integration to connect to the GCP Artifact Registry and push the image.

  1. Navigate to Integrations

  2. Open the Containers tab

  3. Create a new Containers account by pressing the Create button. Create a new Docker Registry account of provider type DockerRegistry

image-20240318-163258.png

It should have a Registry Address, Registry User, and Registry Token/Password configured in it.

To push an image to GCP Artifact Registry, the service account should at least have all permissions of the Artifact Registry Writer.

Git Repository Structure

The Git repository should be a Docker-based application. A Dockerfile should be present in the application to build the image.

A sample Git repository structure is given below:

Build Workflow

Navigate to the Workflows menu and create a workflow using the (blue star) button as highlighted below.

image-20240318-164104.png

The steps of the workflow execution can be configured from the Definition tab. Below is a sample build workflow.

image-20240318-164420.png

Step 1: Clone Project Sources

This step will clone the Git repository codebase into the Project’s execution working directory. The Git URL will be retrieved from Source Control configured under Project configuration.

image-20240318-164611.png

Below is the Git code structure and corresponding exported codebase during execution as a result of the above step.

Git Codebase

EXPORTED CODEBASE

Step 2: Build Image

Below is the Docker plugin (buildImage operation) configuration. This step will build and push a Docker image to the GCP Artifact Registry.

image-20240318-164909.png

The plugin operation by default would look for the Docker File under TEMP directory. In case the Docker File exists in some other folder, the plugin input should specificy the relative from the TEMP directory.

Below is our Git project folder structure. Since our Dockerfile is under the DockerDemo folder in the Git repository, we had to provide the relative path accordingly.

By default, Docker image and image tag details will be retrieved from Project Properties. However, you can always provide these details as a plugin operation input in the buildImage step. Any plugin operation input will take precedence over Project Properties.

We have also marked the Push Image to Repository checkbox to ensure the created image is pushed to the GCP Artifact Registry. The pushImage operation within the Docker plugin can also be used to push the image to the target Docker registry.

If the FlexDeploy Container is properly configured, it would push the image to Docker Registry. In our case, the image is pushed to the GCP Artifact Registry as can be observed below.

After running this build Docker image workflow, information will also be available on the Artifacts tab within the execution details.

Project Configuration

Navigate to Projects and create a Project with a logical name (PushDockerImageToGCPArtifactRegistry in this case)

Configure the build workflow that has been created in previous steps as shown below.

Source Control

Configure the SCM repository on the Source Control tab as shown below.

  1. Select the Sources section for configuring your source repository

  2. Select the appropriate Source Control Type

  3. Configure source repository details. For more detailed steps of source control configuration, please refer to Configure Source Control in FlexDeploy

Project Properties

To configure Project-specific properties, navigate to Configuration → Properties as shown below.

  1. Select the target Registry Account.

  2. Docker Image Name and Docker Image Tag are essential to build the docker image.

Target Properties

Topology

Navigate to Topology. Choose a Target Group on the left, or create a new one. You will see a list of Environments on the right with colored circles representing each Target

Color coding represents:

  • RED - The Endpoint is not configured

  • YELLOW - some of the required properties are not set,

  • GREEN - all required properties are set and the Endpoint is configured

Clicking the environment row for Dev allows modifying the target’s Endpoint and properties. Below are the environment-specific values which need to be provided.

Properties

Mandatory field

Description

Docker Server

Optional

Docker server address. Required if Docker Unix Socket is not set.

Docker Server Port

Optional

The port to connect to on the Docker server.

Docker Unix Socket

Optional

The socket the Docker daemon listens on

The default value is [/var/run/docker.sock]

Registry Account

Optional

Docker Registry account with relevant details

GIT Path

Optional

Path to the Git executable. Required only if git is not on PATH.

Build Execution

From here, for detailed steps on how to initiate build and push a Docker image, please refer to Build Execution through FlexDeploy for Docker Plugin

Congratulations! You have successfully completed the Push Docker Image to GCP Artifact Registry tutorial.

Now that you have configured FlexDeploy to push an image to the GCP Artifact Registry, it is extremely easy to replicate the same for other container registries as well. Simply use the Copy Project feature and a new project will be created with all of the configuration completed already. You just need to make the necessary configuration changes.

 

 

 

 

 

  • No labels