Understanding Continuous Integration, Delivery, and Deployment with a Step‑by‑Step VSTS CI/CD Pipeline and Docker
This article explains the concepts of Continuous Integration, Continuous Delivery, and Continuous Deployment, then walks through a complete VSTS (Azure DevOps) pipeline setup—including project creation, Git configuration, CI build, Release deployment, SSH tasks, Docker image building, and container execution—targeted at automating .NET Core web applications on a cloud server.
What are CI, CD, and Continuous Deployment? CI means that after developers push new code, the system immediately builds and runs unit tests. CD adds automatic deployment of the built artifact to a production‑like environment (e.g., a staging server). Continuous Deployment further automates the final push to the production environment.
More concepts can be found at the linked cheat‑sheet.
Why use CI/CD? It reduces repetitive work and improves efficiency. Instead of installing Jenkins locally, the tutorial uses Microsoft VSTS (Azure DevOps) for a lightweight, cloud‑based solution.
Resources required
A Tencent Cloud Ubuntu server with Docker installed.
A VSTS account to create a free Git repository (up to 5 users).
Step 1 – Create a VSTS project
Step 2 – Create a simple console web application
Install the required NuGet packages.
Note: the application listens on *:5001 (not localhost:5001 ) so Docker can reach it.
Step 3 – Configure VSTS CI
Set up a trigger so that any push to the master branch starts a build.
Select the ASP.NET Core template; ensure the build runs on a Linux agent.
Remove the unnecessary test task.
Step 4 – Configure Release
Add an artifact that downloads the CI output into a folder named _test_netcore-docker .
Create a production environment (empty process) that will run on the Tencent Cloud server via SSH.
Add an SSH task to copy the published files, unzip them, and generate a Dockerfile.
Shell commands used in the task (wrapped in tags):
unzip -q site/drop/TestDotnetcore.zip -d site/drop/ sudo rm -rf site/drop/*.zip touch site/drop/Dockerfile echo "FROM microsoft/aspnetcore:2.0" >> site/drop/Dockerfile echo "COPY . /publish" >> site/drop/Dockerfile echo "WORKDIR /publish" >> site/drop/Dockerfile echo "EXPOSE 5001" >> site/drop/Dockerfile echo "CMD [\"dotnet\", \"TestDotnetcore.dll\"]" >> site/drop/Dockerfile sudo docker build --rm -t test_image -f site/drop/Dockerfile site/drop/ sudo docker ps -q --filter "name=test_netcore" | grep -q . && sudo docker rm -f test_netcore || true sudo docker run --name test_netcore -d -p 5001:5001 test_image:latest if sudo docker images -f "dangling=true" | grep ago --quiet; then sudo docker rmi -f $(sudo docker images -f "dangling=true" -q); fi sudo rm -rf site/dropAfter committing a change to master , the CI pipeline builds the project, the Release pipeline creates the Docker image, runs the container on the cloud server, and the application becomes reachable on port 5001.
The final Docker image test_image and container test_netcore are verified to be running successfully.
Original article: https://www.cnblogs.com/yudongdong/p/9042750.html
DevOps
Share premium content and events on trends, applications, and practices in development efficiency, AI and related technologies. The IDCF International DevOps Coach Federation trains end‑to‑end development‑efficiency talent, linking high‑performance organizations and individuals to achieve excellence.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.