Compare commits
60 Commits
0ea4a0829d
...
test
| Author | SHA1 | Date | |
|---|---|---|---|
| e26c79a9d7 | |||
| ae1440fce3 | |||
| b58b5777fd | |||
| 83dfdc2cc3 | |||
| bbdb27b116 | |||
| 1da1328870 | |||
| 3b5ca4f5b0 | |||
| 1526648d9a | |||
| d1f723c135 | |||
| 423281d071 | |||
| 44fbc613a3 | |||
| a922531f50 | |||
| 9acebb67fe | |||
| e140319a05 | |||
| 3752da6ebe | |||
| 1937d2eaa1 | |||
| c2a8b5c797 | |||
| c584d39270 | |||
| 81e93b0e4e | |||
| 89f619eefa | |||
| b46848dd56 | |||
| 30e0bc2b87 | |||
| 903c17e7f8 | |||
| bd3cba05cb | |||
| 007f606bb6 | |||
| ef6262282d | |||
| 502182a370 | |||
| c6799a146a | |||
| 6bd60452f2 | |||
| 52e24bb8f2 | |||
| a8ad599af2 | |||
| 5dff86c4fa | |||
| 6a29032748 | |||
| 634ad82d2c | |||
| 59c08d2314 | |||
| 496e6b653d | |||
| 4c86a810da | |||
| 1ee31554ce | |||
| 3d1e3f29df | |||
| c03dc29446 | |||
| 24e439558f | |||
| 1917a60867 | |||
| c43ce20bbe | |||
| 26c90e1697 | |||
| a6a32817c5 | |||
| 03574c720f | |||
| 201850a3d4 | |||
| c8aef17e95 | |||
| 8c6b400a2d | |||
| 324e25c24b | |||
| cdeae28f27 | |||
| 671e8b986f | |||
| 176fdb2930 | |||
| a4822ec103 | |||
| dc79c658dd | |||
| c3c52965ed | |||
| 0ded289b1f | |||
| 83505ee117 | |||
| 06ed9d2bad | |||
| 84d18a4745 |
@@ -27,4 +27,6 @@ README.md
|
|||||||
!.git/config
|
!.git/config
|
||||||
!.git/packed-refs
|
!.git/packed-refs
|
||||||
!.git/refs/heads/**
|
!.git/refs/heads/**
|
||||||
|
# Ensure the build output is NOT ignored
|
||||||
|
!**/bin/Release/**/publish/
|
||||||
|
!**/publish/
|
||||||
|
|||||||
161
.drone.yml
161
.drone.yml
@@ -1,143 +1,68 @@
|
|||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: docker
|
type: docker
|
||||||
name: build
|
name: build-and-package
|
||||||
trigger:
|
|
||||||
event:
|
|
||||||
exclude:
|
|
||||||
- promote
|
|
||||||
|
|
||||||
clone:
|
|
||||||
disable: true
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: checkout
|
- name: build-test-publish
|
||||||
image: alpine/git
|
image: nexus.khongisa.co.za/sdk:10.0
|
||||||
commands:
|
commands:
|
||||||
- git clone https://gitea.khongisa.co.za/MngomaLab/webapitest.git .
|
- dotnet restore --source https://nexus.khongisa.co.za/repository/nuget-group/index.json --no-cache
|
||||||
- git checkout ${DRONE_COMMIT}
|
- dotnet build --configuration Release --no-restore
|
||||||
|
- dotnet test --configuration Release --no-build
|
||||||
|
- dotnet publish --configuration Release --no-build
|
||||||
|
|
||||||
- name: dotnet build
|
- name: docker-build-and-push
|
||||||
image: mcr.microsoft.com/dotnet/sdk:8.0
|
image: plugins/docker
|
||||||
commands:
|
settings:
|
||||||
- dotnet build --configuration Release
|
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
|
- name: vulnerability-scan
|
||||||
image: mcr.microsoft.com/dotnet/sdk:8.0
|
image: aquasec/trivy:0.50.1
|
||||||
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
|
|
||||||
environment:
|
environment:
|
||||||
<<: *docker-auth
|
TRIVY_USERNAME: { from_secret: docker_username }
|
||||||
|
TRIVY_PASSWORD: { from_secret: docker_password }
|
||||||
commands:
|
commands:
|
||||||
- mkdir -p /kaniko/.docker
|
- trivy image --image-src remote --exit-code 1 --severity CRITICAL nexus.khongisa.co.za/webapitest:${DRONE_BUILD_NUMBER}
|
||||||
- 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}
|
|
||||||
|
|
||||||
- name: volnerability-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:
|
trigger:
|
||||||
|
branch:
|
||||||
|
- main
|
||||||
event:
|
event:
|
||||||
exclude:
|
exclude:
|
||||||
- promote
|
- 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
|
kind: pipeline
|
||||||
type: docker
|
type: docker
|
||||||
name: golive
|
name: deploy-to-uat
|
||||||
depends_on:
|
|
||||||
- deploy
|
|
||||||
|
|
||||||
clone:
|
depends_on:
|
||||||
disable: true
|
- build-and-package
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: prod
|
- name: uat-deployment
|
||||||
image: appleboy/drone-ssh
|
image: appleboy/drone-ssh
|
||||||
settings:
|
settings:
|
||||||
host:
|
host: { from_secret: ssh_host }
|
||||||
from_secret: ssh_host
|
username: { from_secret: ssh_user }
|
||||||
username:
|
password: { from_secret: ssh_password }
|
||||||
from_secret: ssh_user
|
|
||||||
password:
|
|
||||||
from_secret: ssh_password
|
|
||||||
script:
|
script:
|
||||||
- docker pull khwezi/webapitest:latest
|
- echo $DOCKER_PASSWORD | docker login nexus.khongisa.co.za -u $DOCKER_USERNAME --password-stdin
|
||||||
- docker stop webapi || true
|
- docker pull nexus.khongisa.co.za/webapitest:latest
|
||||||
- docker rm webapi || true
|
- docker stop webapi 2>/dev/null || true
|
||||||
- docker run -d --name webapi -e ASPNETCORE_ENVIRONMENT=Production -p 4001:8081 khwezi/webapitest:latest
|
- docker rm webapi 2>/dev/null || true
|
||||||
when:
|
- docker run -d --name webapi --restart unless-stopped -e ASPNETCORE_ENVIRONMENT=Development -p 4000:8081 nexus.khongisa.co.za/webapitest:latest
|
||||||
event:
|
environment:
|
||||||
- promote
|
DOCKER_USERNAME: { from_secret: docker_username }
|
||||||
target:
|
DOCKER_PASSWORD: { from_secret: docker_password }
|
||||||
- prod
|
|
||||||
|
trigger:
|
||||||
|
event:
|
||||||
|
- promote
|
||||||
|
target:
|
||||||
|
- staging
|
||||||
@@ -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
|
WORKDIR /app
|
||||||
|
|
||||||
USER 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
|
EXPOSE 8081
|
||||||
ENV ASPNETCORE_HTTP_PORTS=8081
|
ENV ASPNETCORE_HTTP_PORTS=8081
|
||||||
|
|||||||
43
SampleApi/Controllers/DemoController.cs
Normal file
43
SampleApi/Controllers/DemoController.cs
Normal 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)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<UserSecretsId>cfe6b4ce-2d40-4273-b3a3-e4df67304fc5</UserSecretsId>
|
<UserSecretsId>cfe6b4ce-2d40-4273-b3a3-e4df67304fc5</UserSecretsId>
|
||||||
@@ -9,8 +9,9 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.23.0" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
<PackageReference Include="Polly" Version="8.6.6" />
|
||||||
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.7" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Reference in New Issue
Block a user