SECRET OF CSS

Web3 Meets DevOps: Pipeline, Prod | by Donovan Brown | Sep, 2022


Web3 needs DevOps

Part 10 — Building a DevOps pipeline for the Ethereum blockchain

0*l7sFZ5 7u0lmJUQc
Photo by Taylor Vick on Unsplash

In the previous post of this series — Web3 Meets DevOps: Pipeline, QA — I deployed the application to my QA environment. In this post, I will cover what it takes to deploy to the Ethereum Mainnet.

I created a new branch named “blog/part10” for this article.

git checkout -b blog/part10

To deploy to Mainnet, I need an Infura node like I used for Rinkeby. Unlike with Rinkeby, I need an account with Ether. Using the same project I created in the previous post, I got my Network Endpoints for Mainnet. The API KEY is the same for all networks.

1*JsidBEqUFRaPT diFAhn w
Infura Project Settings (Mainnet)

To deploy to Mainnet the network must be added to the truffle-config.js. The best resource for adding the network is the official Truffle Suite docs.

As with Rinkeby, using the HDWalletProvider, I added the Mainnet to the networks section.

Infrastructure

Under the iac job of the prod stage, in azure-pipelines.yml, I added two tasks, as shown below:

The first task downloads the iac artifact created during the build stage of the pipeline. This artifact contains three Bicep files and a PowerShell script.

The second task executes the PowerShell script, which uses the three Bicep files to deploy an Azure Static Web App. I use the -rgName $(resourceGroup)-prod argument, which puts all the resources in a resource group for my production environment. Notice the use of the service connection I created earlier as the value of the azureSubscription under inputs.

Contracts

The contracts are deployed into the Mainnet using the Infura node. Under the deploy_contracts job of the prod stage, I added the following:

Notice on line 12 that I pass in mainnet to the --network argument and set the appropriate environment variables for the API KEY and MNEMONIC.

Unlike the Dev and QA environments, there is no need to delete the resources as part of the pipeline. So, there is no manual approval to delete the resource group.

The frontend will be deployed into the Azure Static Web App deployed in the iac job of the prod stage. Under the deploy_frontend job of the prod stage, I added the following:

Variables

This stage reuses the variables created in the QA environment in part 9.

1*aX8KRoeMkWKWYvMkkEoGhA
Two variables added to pipeline

Once the pipeline completed, the Prod environment information was added to the Extensions section of the run.

1*ef8Kzg1dfr6OuKn P3p hA

This series documented the process of applying DevOps best practices to Web3 development. This could be extended by adding additional tools, such as code and dependency scanning, static code analysis, and integration tests.

No matter the type of software you are developing, implementing DevOps best practices will add value and improve your team’s velocity, all while reducing errors.

Thanks for reading. Until next time!



News Credit

%d bloggers like this: