Compare commits

...

61 Commits

Author SHA1 Message Date
e26c79a9d7 Removed pull event from build stage 2026-04-04 16:39:31 +02:00
ae1440fce3 Refactored uat to staging 2026-04-04 16:38:30 +02:00
b58b5777fd Refactored triggers 2026-04-04 16:38:02 +02:00
83dfdc2cc3 Removed promotion trigger 2026-04-04 16:35:19 +02:00
bbdb27b116 Removed promotion trigger 2026-04-04 16:34:41 +02:00
1da1328870 Removed build stage dependency 2026-04-04 16:29:17 +02:00
3b5ca4f5b0 Removed triggers on build stage 2026-04-04 16:25:09 +02:00
1526648d9a Light refactor 2026-04-04 16:24:12 +02:00
d1f723c135 Added pull_request trigger in build stage 2026-04-04 16:22:59 +02:00
423281d071 Removed push trigger from build branch 2026-04-04 16:19:44 +02:00
44fbc613a3 Enhanced triggers 2026-04-04 16:17:40 +02:00
a922531f50 Fixed pipeline stage naming 2026-04-04 16:13:03 +02:00
9acebb67fe Split deployment from main pipeline 2026-04-04 16:11:17 +02:00
e140319a05 Removed comments 2026-04-04 15:58:58 +02:00
3752da6ebe fixed dotnet step image 2026-04-04 15:58:12 +02:00
1937d2eaa1 Restored drone image detection 2026-04-04 15:56:51 +02:00
c2a8b5c797 removed tags 2026-04-04 15:54:19 +02:00
c584d39270 Applied nexus to all docker references including docker image 2026-04-04 15:51:52 +02:00
81e93b0e4e Refactored nexus trivy manifest 2026-04-04 15:41:54 +02:00
89f619eefa Pointing to the right .net10 image on nexus 2026-04-04 15:40:55 +02:00
b46848dd56 Refactored the pipeline to pull the trivy image from nexus as well 2026-04-04 15:33:03 +02:00
30e0bc2b87 Pulling .net docker image from nexus 2026-04-04 15:32:20 +02:00
903c17e7f8 Refactored the pipeline so that docker push happens before the trivy scan 2026-04-04 15:30:56 +02:00
bd3cba05cb Fixed docker steps to use local nexus properly 2026-04-04 15:24:06 +02:00
007f606bb6 Supplied full package source for nuget 2026-04-04 15:12:55 +02:00
ef6262282d Applied specific trivy version 2026-04-04 15:10:28 +02:00
502182a370 Using nexus for dotnet restore 2026-04-04 15:09:05 +02:00
c6799a146a Added publish step to dotnet 2026-04-04 15:06:32 +02:00
6bd60452f2 Ensured donet publish and release are not ignored 2026-04-04 15:02:08 +02:00
52e24bb8f2 Upgraded packages and refactored the pipeline 2026-04-04 14:53:33 +02:00
a8ad599af2 Removed dolive stage 2026-03-14 11:50:02 +02:00
5dff86c4fa SImplified prod docker step 2026-03-14 11:41:25 +02:00
6a29032748 Refactored prod step 2026-03-14 11:33:43 +02:00
634ad82d2c Unified docker commands 2026-03-14 11:23:44 +02:00
59c08d2314 Using temporary folder 2026-03-14 11:18:50 +02:00
496e6b653d Fixed docker config path error 2026-03-14 11:13:10 +02:00
4c86a810da fixed temp directory naming 2026-03-14 11:07:00 +02:00
1ee31554ce Fixed yaml syntax error 2026-03-14 11:01:07 +02:00
3d1e3f29df switched to powershell commands on prod step 2026-03-14 11:00:11 +02:00
c03dc29446 fixed yaml syntax error 2026-03-14 10:54:16 +02:00
24e439558f Refactored to fix yaml syntax error 2026-03-14 10:52:19 +02:00
1917a60867 Added measures to ignore docker credential store 2026-03-14 10:50:01 +02:00
c43ce20bbe Added silent removal of existing containers 2026-03-14 10:43:50 +02:00
26c90e1697 Fixed docker commands on prod step 2026-03-14 10:38:05 +02:00
a6a32817c5 Retrieving host from secrets 2026-03-14 10:32:23 +02:00
03574c720f Refactored container names 2026-03-14 10:31:41 +02:00
201850a3d4 Removed variable expansion because plugin doesnt support it 2026-03-14 10:25:15 +02:00
c8aef17e95 Added restart conditions 2026-03-14 10:15:35 +02:00
8c6b400a2d Refactored prod stage 2026-03-14 10:12:55 +02:00
324e25c24b Credential refactor 2026-03-10 19:28:58 +02:00
cdeae28f27 Refactored prod stage 2026-03-10 19:23:33 +02:00
671e8b986f Refactored prod step to target the correct docker folder for user 2026-03-10 19:19:49 +02:00
176fdb2930 Refactored prod step 2026-03-10 19:17:34 +02:00
a4822ec103 Refactored golive stage to use prod secrets 2026-03-10 19:02:42 +02:00
dc79c658dd Refactored golive stage to use prod host as a target for our deployment 2026-03-10 18:31:28 +02:00
c3c52965ed Added demo controller 2026-03-09 16:56:20 +02:00
0ded289b1f Fixed pipeline to support .net 10 2026-03-08 14:47:01 +02:00
83505ee117 Fixed SDK dockerfile reference 2026-03-08 14:45:16 +02:00
06ed9d2bad Upgraded Dockerfile image from .net 8 to 10 2026-03-08 14:42:33 +02:00
84d18a4745 Upgraded to .nwt 10 2026-03-08 14:41:44 +02:00
1fa3f6bb4b Light refactor 2026-03-08 14:25:53 +02:00
5 changed files with 95 additions and 129 deletions

View File

@@ -27,4 +27,6 @@ README.md
!.git/config
!.git/packed-refs
!.git/refs/heads/**
# Ensure the build output is NOT ignored
!**/bin/Release/**/publish/
!**/publish/

View File

@@ -1,148 +1,68 @@
---
kind: pipeline
type: docker
name: build
trigger:
event:
exclude:
- promote
clone:
disable: true
name: build-and-package
steps:
- name: checkout
image: alpine/git
- name: build-test-publish
image: nexus.khongisa.co.za/sdk:10.0
commands:
- git clone https://gitea.khongisa.co.za/MngomaLab/webapitest.git .
- git checkout ${DRONE_COMMIT}
- dotnet restore --source https://nexus.khongisa.co.za/repository/nuget-group/index.json --no-cache
- dotnet build --configuration Release --no-restore
- dotnet test --configuration Release --no-build
- dotnet publish --configuration Release --no-build
- name: dotnet build
image: mcr.microsoft.com/dotnet/sdk:8.0
commands:
- dotnet build --configuration Release
- name: docker-build-and-push
image: plugins/docker
settings:
registry: nexus.khongisa.co.za
repo: nexus.khongisa.co.za/webapitest
tags: [ "${DRONE_BUILD_NUMBER}", "latest" ]
username: { from_secret: docker_username }
password: { from_secret: docker_password }
- name: dotnet test
image: mcr.microsoft.com/dotnet/sdk:8.0
commands:
- dotnet test --configuration Release
---
x-docker-auth: &docker-auth
DOCKER_AUTH_CONFIG: |
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "a2h3ZXppOlBHM0FRM0VPMFg="
}
}
}
kind: pipeline
type: docker
name: package
depends_on:
- build
trigger:
event:
exclude:
- promote
clone:
disable: true
steps:
- name: checkout
image: alpine/git
commands:
- git clone https://gitea.khongisa.co.za/MngomaLab/webapitest.git .
- git checkout ${DRONE_COMMIT}
- name: dotnet publish
image: mcr.microsoft.com/dotnet/sdk:8.0
commands:
- dotnet publish --configuration Release
- name: build and push
image: gcr.io/kaniko-project/executor:debug
- name: vulnerability-scan
image: aquasec/trivy:0.50.1
environment:
<<: *docker-auth
TRIVY_USERNAME: { from_secret: docker_username }
TRIVY_PASSWORD: { from_secret: docker_password }
commands:
- mkdir -p /kaniko/.docker
- echo "$DOCKER_AUTH_CONFIG" > /kaniko/.docker/config.json
- /kaniko/executor
--verbosity=debug
--context=.
--dockerfile=Dockerfile
--destination=index.docker.io/khwezi/webapitest:latest
--destination=index.docker.io/khwezi/webapitest:${DRONE_BUILD_NUMBER}
- trivy image --image-src remote --exit-code 1 --severity CRITICAL nexus.khongisa.co.za/webapitest:${DRONE_BUILD_NUMBER}
- name: volnerability-scan
image: aquasec/trivy
commands:
- trivy image --exit-code 1 --severity CRITICAL khwezi/webapitest:${DRONE_BUILD_NUMBER}
- name: container-scan
image: aquasec/trivy
commands:
- trivy image --exit-code 1 --severity CRITICAL khwezi/webapitest:${DRONE_BUILD_NUMBER}
---
kind: pipeline
type: docker
name: deploy
depends_on:
- package
trigger:
branch:
- main
event:
exclude:
- promote
clone:
disable: true
steps:
- name: uat
image: appleboy/drone-ssh
settings:
host:
from_secret: ssh_host
username:
from_secret: ssh_user
password:
from_secret: ssh_password
script:
- docker pull khwezi/webapitest:latest
- docker stop webapitest || true
- docker rm webapitest || true
- docker run -d --name webapitest -e ASPNETCORE_ENVIRONMENT=Development -p 4000:8081 khwezi/webapitest:latest
---
kind: pipeline
type: docker
name: golive
depends_on:
- deploy
name: deploy-to-uat
clone:
disable: true
depends_on:
- build-and-package
steps:
- name: prod
- name: uat-deployment
image: appleboy/drone-ssh
settings:
host:
from_secret: ssh_host
username:
from_secret: ssh_user
password:
from_secret: ssh_password
host: { from_secret: ssh_host }
username: { from_secret: ssh_user }
password: { from_secret: ssh_password }
script:
- docker pull khwezi/webapitest:latest
- docker stop webapi || true
- docker rm webapi || true
- docker run -d --name webapi -e ASPNETCORE_ENVIRONMENT=Production -p 4001:8081 khwezi/webapitest:latest
when:
event:
- promote
target:
- prod
- echo $DOCKER_PASSWORD | docker login nexus.khongisa.co.za -u $DOCKER_USERNAME --password-stdin
- docker pull nexus.khongisa.co.za/webapitest:latest
- docker stop webapi 2>/dev/null || true
- docker rm webapi 2>/dev/null || true
- docker run -d --name webapi --restart unless-stopped -e ASPNETCORE_ENVIRONMENT=Development -p 4000:8081 nexus.khongisa.co.za/webapitest:latest
environment:
DOCKER_USERNAME: { from_secret: docker_username }
DOCKER_PASSWORD: { from_secret: docker_password }
trigger:
event:
- promote
target:
- staging

View File

@@ -1,9 +1,9 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final
FROM nexus.khongisa.co.za/aspnet:10.0 AS final
WORKDIR /app
USER app
COPY --chown=app:app ./SampleApi/bin/Release/net8.0/publish/ .
COPY --chown=app:app ./SampleApi/bin/Release/net10.0/publish/ .
EXPOSE 8081
ENV ASPNETCORE_HTTP_PORTS=8081

View File

@@ -0,0 +1,43 @@
using Microsoft.AspNetCore.Mvc;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace SampleApi.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class DemoController : ControllerBase
{
// GET: api/<DemoController>
[HttpGet]
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
// GET api/<DemoController>/5
[HttpGet("{id}")]
public string Get(int id)
{
return "value";
}
// POST api/<DemoController>
[HttpPost]
public void Post([FromBody] string value)
{
}
// PUT api/<DemoController>/5
[HttpPut("{id}")]
public void Put(int id, [FromBody] string value)
{
}
// DELETE api/<DemoController>/5
[HttpDelete("{id}")]
public void Delete(int id)
{
}
}
}

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>cfe6b4ce-2d40-4273-b3a3-e4df67304fc5</UserSecretsId>
@@ -9,8 +9,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.23.0" />
<PackageReference Include="Polly" Version="8.6.6" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.7" />
</ItemGroup>
</Project>