Table of Contents | ||||
---|---|---|---|---|
|
Objective
You have a working docker Docker project and the source code is managed in a Git repository. The goal of the tutorial is to push a docker Docker image to the GCP Artifact Registry.
This process will include:
cloning the application from a Git repository
building the docker Docker image
push pushing the docker Docker image to the GCP Artifact Registry.
We will walk through each of the FlexDeploy features items that will need to be created/configured to accomplish this goal and have the docker 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 the this document. : Docker Registry Setup For Cloud Providers
Configure Container Account
Configure GCP Container Account container account under Topology. FlexDeploy will use this integration to connect to the GCP Artifact Registry and push the image.
Navigate to the Topology TabSelect Integrationsfrom the left-hand paneNavigate to
Open the Containers tab under Topology
Create a new Containers account with the “+” by pressing the Create button. Create a new Docker Registry account of provider type “DockerRegistry” DockerRegistry
...
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 service account should at least have all permission permissions of the Artifact Registry Writer.
...
.
...
...
next update the GCP Service Account key file content under Secret Text. This is to make sure no one else can retrieve the password
...
Git Repository Structure
The Git repository should be a docker Docker-based application. A Dockerfile should be present in the application to build docker the image.
The Sample A sample Git repository structure is given below:
...
Build Workflow
Navigate to the Workflows tab menu and create a workflow using the “+”(Click to create new Workflow) button as highlighted below.
...
Next, create one Build workflow as shown below. The workflow Type field defines the type of workflow.
Build Workflow
Navigate to the Workflows Tab
Select the “+” button from the left-hand pane to create a new workflow with type as Build.
...
The Workflow Group and Subgroup define the folder hierarchy. Once both workflows are created it should look like the below. No constraint on workflow or folder naming convention.
...
The steps of the workflow execution can be configured through from the Workflow Definition section tab.
...
Below given is a sample build workflow to build and push docker image to the GCP Artifact Registry.
...
Step -i1: Clone Git RepositoryProject Sources
This step will clone the Git repository codebase into the project Project’s execution working directory. The Git URL will be retrieved from Source Control configured under Project Configurationconfiguration.
...
Below given is the Git code structure and corresponding exported codebase during execution as a result of the above step.
Git Codebase
...
EXPORTED CODEBASE
...
Step-ii2: Build and Push the docker image to the GCP Artifact RegistryImage
Below given is the Docker plugin (buildImage operation) configurationsconfiguration. The below This step will build and push docker a Docker image to the GCP Artifact Registry.
...
The plugin operation by default would look for Dokerfile the Docker File under TEMP directory. In case the same exist Docker File exists in some other folder, relative path has to be specified from the plugin input should specificy the relative from the TEMP directory.
Below given is the 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 , Docker image and image tag details will be retrieved from Project Properties. However, one you can always provide the these details as part of the a plugin operation input (highlighted in above in the buildImage step. Any plugin operation diagram). Plugin operation input shall will take precedence over Project Properties.
We have also marked the “Push Image to Repository” checkbox to ensure the created image is push pushed to the GCP Artifact Registry. The pushImage operation under within the Docker plugin can also be used to push the image to the target Docker Registryregistry.
If the FlexDeploy Container Registry Account 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 Build docker image running this build Docker image workflow, information will also be available in on the Artifacts sectiontab within the execution details.
...
Project
...
Configuration
Navigate to the Project tab Projects and create a Project with a logical name (PushDockerImageToGCPArtifactRegistry in this case)
...
Configure the Build build workflow that has been created in previous steps as shown below.
...
Anchor | ||||
---|---|---|---|---|
|
Configure the Source SCM repository under on the Source Control tabas shown below.
...
To configure Project specific Source Control one first need to navigate to the Project Configuration tab.
Next, expand the SOURCE CONTROL option from the left-hand pane.
Select SOURCES for configuring the Source RepositorySelect the Sources section for configuring your source repository
Select the appropriate Source Control Type
Configure Source Repositorysource repositorydetails. For more detailed steps of Source Control source control configuration, please refer to Configure Source Control in FlexDeploy
Anchor | ||||
---|---|---|---|---|
|
To configure Project-specific settings one can properties, navigate to Configuration → Properties as shown below.
...
To configure Project specific settings one can navigate to the Project Configuration tab as shown above.
Next, select the PROPERTIES option from the left-hand pane.
Select the target Registry Account.
Docker Image Name and Docker Image Tag are essential to build the docker image.
Target Properties
Topology
Navigate to the Topologyfrom the Menu. The Page with the Target Groups, Environments and Endpoints sections will be displayed. 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.
...
Click on Docker Target Group and click on the Development EnvironmentColor 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 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. |
Below given are the env-specific values which need to be updated.
...
Build Execution
For From here, for detailed steps on how to initiate Build build and push docker a Docker image, please refer to Build execution Execution through FlexDeploy for Docker pluginPlugin
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 Registry 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.
...