Compare commits
23 Commits
test
...
d801f96fb9
| Author | SHA1 | Date | |
|---|---|---|---|
| d801f96fb9 | |||
| 1cc3750fa3 | |||
| e38dff6e92 | |||
| c4b125a580 | |||
| c9de909eb6 | |||
| 7eb870a29c | |||
| 83c7844880 | |||
| 69b92e9323 | |||
| fcfd265c46 | |||
| bc3a44d5ea | |||
| cded235985 | |||
| f15143349e | |||
| 7d8f15104c | |||
| e2b5f2db8c | |||
| 57ba629d2d | |||
| d30ee959ee | |||
| 4e653fd91d | |||
| b4ee875ac8 | |||
| 7d395e2295 | |||
| ddc66efc16 | |||
| 82348a0112 | |||
| e495be1c0b | |||
| 5a530210c0 |
@@ -27,6 +27,4 @@ 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/
|
|
||||||
|
|||||||
70
.drone.yml
70
.drone.yml
@@ -1,68 +1,20 @@
|
|||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: docker
|
type: docker
|
||||||
name: build-and-package
|
name: package
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: build-test-publish
|
- name: dotnet publish
|
||||||
image: nexus.khongisa.co.za/sdk:10.0
|
image: mcr.microsoft.com/dotnet/sdk:8.0
|
||||||
commands:
|
commands:
|
||||||
- dotnet restore --source https://nexus.khongisa.co.za/repository/nuget-group/index.json --no-cache
|
- dotnet publish --configuration Release
|
||||||
- dotnet build --configuration Release --no-restore
|
- ls ./SampleApi/bin/Release/net8.0/publish/
|
||||||
- dotnet test --configuration Release --no-build
|
|
||||||
- dotnet publish --configuration Release --no-build
|
|
||||||
|
|
||||||
- name: docker-build-and-push
|
- name: docker build and push
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
settings:
|
settings:
|
||||||
registry: nexus.khongisa.co.za
|
repo: gitea.khongisa.co.za/khwezi/sampleapi
|
||||||
repo: nexus.khongisa.co.za/webapitest
|
registry: registry.khongisa.co.za:3005
|
||||||
tags: [ "${DRONE_BUILD_NUMBER}", "latest" ]
|
insecure: true
|
||||||
username: { from_secret: docker_username }
|
dockerfile: Dockerfile
|
||||||
password: { from_secret: docker_password }
|
context: .
|
||||||
|
|
||||||
- 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
|
|
||||||
@@ -1,11 +1,9 @@
|
|||||||
FROM nexus.khongisa.co.za/aspnet:10.0 AS final
|
FROM mcr.microsoft.com/dotnet/aspnet:8.0
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
USER app
|
COPY ./SampleApi/bin/Release/net8.0/publish/ .
|
||||||
|
|
||||||
COPY --chown=app:app ./SampleApi/bin/Release/net10.0/publish/ .
|
|
||||||
|
|
||||||
EXPOSE 8081
|
|
||||||
ENV ASPNETCORE_HTTP_PORTS=8081
|
ENV ASPNETCORE_HTTP_PORTS=8081
|
||||||
|
EXPOSE 8081
|
||||||
|
|
||||||
ENTRYPOINT ["dotnet", "SampleApi.dll"]
|
ENTRYPOINT ["dotnet", "SampleApi.dll"]
|
||||||
@@ -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)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +1,25 @@
|
|||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
// Add services to the container.
|
||||||
|
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
builder.Services.AddSwaggerGen();
|
builder.Services.AddSwaggerGen();
|
||||||
builder.Services.AddHealthChecks();
|
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
|
// Configure the HTTP request pipeline.
|
||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
app.UseSwagger();
|
app.UseSwagger();
|
||||||
app.UseSwaggerUI();
|
app.UseSwaggerUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
app.MapHealthChecks("/health");
|
|
||||||
app.UseRouting();
|
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net10.0</TargetFramework>
|
<TargetFramework>net8.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,9 +9,8 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.23.0" />
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />
|
||||||
<PackageReference Include="Polly" Version="8.6.6" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.7" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Reference in New Issue
Block a user