Compare commits

..

15 Commits

Author SHA1 Message Date
fcfd265c46 Merge pull request 'Flattened pipeline stages' (#16) from test into main
Some checks failed
continuous-integration/drone Build is failing
Reviewed-on: $scheme://$host/MngomaLab/webapitest/pulls/16
2026-03-07 11:23:56 +02:00
bc3a44d5ea Merge pull request 'Changed pipeline type from kubernetes to docker' (#15) from test into main
Some checks failed
continuous-integration/drone Build encountered an error
Reviewed-on: $scheme://$host/MngomaLab/webapitest/pulls/15
2026-03-07 11:19:11 +02:00
cded235985 Merge pull request 'test' (#14) from test into main
Some checks failed
continuous-integration/drone Build encountered an error
Reviewed-on: $scheme://$host/MngomaLab/webapitest/pulls/14
2026-03-07 11:14:59 +02:00
f15143349e Merge pull request 'Refactored docker-compose.yml to expose ports and specify environment' (#13) from test into main
Some checks failed
continuous-integration/drone Build was killed
Reviewed-on: #13
2026-03-03 17:46:35 +02:00
7d8f15104c Merge pull request 'Refactored dockerfile stage 2 ports exposure' (#12) from test into main
Reviewed-on: #12
2026-03-03 17:43:34 +02:00
e2b5f2db8c Merge pull request 'Exposed ports on dockerfile' (#11) from test into main
Reviewed-on: #11
2026-03-03 17:41:06 +02:00
57ba629d2d Merge pull request 'Refactored dockerfile' (#10) from test into main
Reviewed-on: #10
2026-03-03 17:34:50 +02:00
d30ee959ee Merge pull request 'Refactored docker file' (#9) from test into main
Reviewed-on: #9
2026-03-03 17:27:19 +02:00
4e653fd91d Merge pull request 'Refactored docker file' (#8) from test into main
Reviewed-on: #8
2026-03-03 15:06:12 +02:00
b4ee875ac8 Merge pull request 'Added debug lines' (#7) from test into main
Reviewed-on: #7
2026-03-03 14:57:27 +02:00
7d395e2295 Merge pull request 'Refactored paths' (#6) from test into main
Reviewed-on: #6
2026-03-03 14:56:07 +02:00
ddc66efc16 Merge pull request 'test' (#5) from test into main
Reviewed-on: #5
2026-03-03 14:54:08 +02:00
82348a0112 Merge pull request 'Refactored dockerfile' (#4) from test into main
Reviewed-on: #4
2026-03-03 14:50:40 +02:00
e495be1c0b Merge pull request 'Fixed docker image typo' (#3) from test into main
Reviewed-on: #3
2026-03-03 14:44:38 +02:00
5a530210c0 Merge pull request 'Refactored docker file image to SDK' (#2) from test into main
Reviewed-on: #2
2026-03-03 13:38:04 +02:00
6 changed files with 47 additions and 118 deletions

View File

@@ -12,6 +12,7 @@
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
@@ -26,7 +27,4 @@ README.md
!.git/HEAD
!.git/config
!.git/packed-refs
!.git/refs/heads/**
# Ensure the build output is NOT ignored
!**/bin/Release/**/publish/
!**/publish/
!.git/refs/heads/**

View File

@@ -1,68 +1,24 @@
---
kind: pipeline
type: docker
name: build-and-package
name: package
steps:
- name: build-test-publish
image: nexus.khongisa.co.za/sdk:10.0
- name: dotnet publish
image: mcr.microsoft.com/dotnet/sdk:8.0
commands:
- 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
- dotnet publish --configuration Release
- ls ./SampleApi/bin/Release/net8.0/publish/
- name: docker-build-and-push
- 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: vulnerability-scan
image: aquasec/trivy:0.50.1
environment:
TRIVY_USERNAME: { from_secret: docker_username }
TRIVY_PASSWORD: { from_secret: docker_password }
commands:
- trivy image --image-src remote --exit-code 1 --severity CRITICAL nexus.khongisa.co.za/webapitest:${DRONE_BUILD_NUMBER}
trigger:
branch:
- main
event:
exclude:
- promote
---
kind: pipeline
type: docker
name: deploy-to-uat
depends_on:
- build-and-package
steps:
- name: uat-deployment
image: appleboy/drone-ssh
settings:
host: { from_secret: ssh_host }
username: { from_secret: ssh_user }
password: { from_secret: ssh_password }
script:
- 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
repo: gitea.khongisa.co.za/khwezi/sampleapi
registry: gitea.khongisa.co.za
insecure: false
username:
from_secret: gitea-username
password:
from_secret: gitea-password
dockerfile: Dockerfile
context: ./SampleApi/bin/Release/net8.0/publish/

View File

@@ -1,11 +1,27 @@
FROM nexus.khongisa.co.za/aspnet:10.0 AS final
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["SampleApi/SampleApi.csproj", "SampleApi/"]
RUN dotnet restore "SampleApi/SampleApi.csproj"
COPY . .
RUN dotnet publish "SampleApi/SampleApi.csproj" \
-c Release \
-o /app/publish \
--no-restore \
/p:UseAppHost=false
FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
USER app
COPY --chown=app:app ./SampleApi/bin/Release/net10.0/publish/ .
ENV ASPNETCORE_HTTP_PORTS=8081
EXPOSE 8081
COPY --from=build /app/publish .
RUN ls -la /app
ENV ASPNETCORE_HTTP_PORTS=8081
ENTRYPOINT ["dotnet", "SampleApi.dll"]

View File

@@ -1,43 +0,0 @@
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,22 +1,25 @@
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddHealthChecks();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.MapHealthChecks("/health");
app.UseRouting();
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();

View File

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