Compare commits
84 Commits
test
...
21e4c3940a
| Author | SHA1 | Date | |
|---|---|---|---|
| 21e4c3940a | |||
| 0c901d32d8 | |||
| 38cbf5b656 | |||
| 1263ad8571 | |||
| 8d12af4e10 | |||
| 099bc0c515 | |||
| 1cb1481ab8 | |||
| f6bcbb6674 | |||
| 6f395f9db7 | |||
| 080d09fca3 | |||
| 18bc75b687 | |||
| dd5ad891ab | |||
| 247aa96d19 | |||
| de0820dcc2 | |||
| 7071441d12 | |||
| 48b884ae72 | |||
| 1e66974684 | |||
| b3fa0e5138 | |||
| 900e72779f | |||
| 28d02037f8 | |||
| 5e00dd6726 | |||
| 5ee124790f | |||
| 8b23dfa534 | |||
| 42361d94a8 | |||
| 5cc239854e | |||
| 3ce3d88fae | |||
| 71dd02a122 | |||
| 45c3c77bb3 | |||
| 0ea4a0829d | |||
| 467a385c2a | |||
| 06a910e894 | |||
| 2372a8a24a | |||
| 4eb185aece | |||
| 64ac839d3c | |||
| c81a4451d6 | |||
| 9116076bac | |||
| 1a8e9abb3e | |||
| 09558ce984 | |||
| a20c90039b | |||
| da229bf4ec | |||
| 6bc8e5e703 | |||
| 8fce29f5ab | |||
| 79a3d87668 | |||
| 833bfafa7f | |||
| 2477602874 | |||
| 8afd460a3c | |||
| 10d9186f92 | |||
| 41538c6376 | |||
| 94ad00974d | |||
| 45171382f0 | |||
| eb4884eab5 | |||
| 2b3bd2897c | |||
| 1831c79554 | |||
| 909b9e742a | |||
| bec8ce3e74 | |||
| 6ee84199b2 | |||
| 895bce48d2 | |||
| 087358efc6 | |||
| d828595384 | |||
| 8cff952b17 | |||
| 1af6ceb288 | |||
| d801f96fb9 | |||
| 1cc3750fa3 | |||
| e38dff6e92 | |||
| c4b125a580 | |||
| c9de909eb6 | |||
| 7eb870a29c | |||
| 83c7844880 | |||
| 69b92e9323 | |||
| fcfd265c46 | |||
| bc3a44d5ea | |||
| cded235985 | |||
| f15143349e | |||
| 7d8f15104c | |||
| e2b5f2db8c | |||
| 57ba629d2d | |||
| d30ee959ee | |||
| 4e653fd91d | |||
| b4ee875ac8 | |||
| 7d395e2295 | |||
| ddc66efc16 | |||
| 82348a0112 | |||
| e495be1c0b | |||
| 5a530210c0 |
98
.drone.yml
98
.drone.yml
@@ -1,68 +1,82 @@
|
|||||||
---
|
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: docker
|
type: docker
|
||||||
name: build-and-package
|
name: cicd-pipeline
|
||||||
|
|
||||||
|
# Let Drone handle the clone automatically; it's faster and cleaner.
|
||||||
|
clone:
|
||||||
|
depth: 1
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: build-test-publish
|
# --- BUILD & TEST STAGE ---
|
||||||
image: nexus.khongisa.co.za/sdk:10.0
|
- name: build-and-test
|
||||||
|
image: mcr.microsoft.com/dotnet/sdk:10.0
|
||||||
commands:
|
commands:
|
||||||
- dotnet restore --source https://nexus.khongisa.co.za/repository/nuget-group/index.json --no-cache
|
- dotnet build --configuration Release
|
||||||
- dotnet build --configuration Release --no-restore
|
- dotnet test --configuration Release
|
||||||
- dotnet test --configuration Release --no-build
|
|
||||||
- dotnet publish --configuration Release --no-build
|
|
||||||
|
|
||||||
- name: docker-build-and-push
|
# --- PACKAGE STAGE ---
|
||||||
|
# We build the image locally first so we can scan it BEFORE pushing
|
||||||
|
- name: docker-build
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
settings:
|
settings:
|
||||||
registry: nexus.khongisa.co.za
|
registry: nexus.khongisa.co.za
|
||||||
repo: nexus.khongisa.co.za/webapitest
|
repo: nexus.khongisa.co.za/mngomalab/webapitest
|
||||||
tags: [ "${DRONE_BUILD_NUMBER}", "latest" ]
|
tags: [ "${DRONE_BUILD_NUMBER}", "latest" ]
|
||||||
username: { from_secret: docker_username }
|
username:
|
||||||
password: { from_secret: docker_password }
|
from_secret: docker_username
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
# This builds the image and loads it into the local cache for scanning
|
||||||
|
dry_run: true
|
||||||
|
# Set to false once you verify the scan passes, or see the step below
|
||||||
|
|
||||||
- name: vulnerability-scan
|
- name: vulnerability-scan
|
||||||
image: aquasec/trivy:0.50.1
|
image: aquasec/trivy
|
||||||
environment:
|
environment:
|
||||||
TRIVY_USERNAME: { from_secret: docker_username }
|
# Trivy needs these to pull the image from your Nexus to scan it
|
||||||
TRIVY_PASSWORD: { from_secret: docker_password }
|
TRIVY_USERNAME:
|
||||||
|
from_secret: docker_username
|
||||||
|
TRIVY_PASSWORD:
|
||||||
|
from_secret: docker_password
|
||||||
commands:
|
commands:
|
||||||
- trivy image --image-src remote --exit-code 1 --severity CRITICAL nexus.khongisa.co.za/webapitest:${DRONE_BUILD_NUMBER}
|
- trivy image --exit-code 1 --severity CRITICAL nexus.khongisa.co.za/mngomalab/webapitest:${DRONE_BUILD_NUMBER}
|
||||||
|
|
||||||
trigger:
|
- name: docker-push
|
||||||
branch:
|
image: plugins/docker
|
||||||
- main
|
settings:
|
||||||
event:
|
registry: nexus.khongisa.co.za
|
||||||
exclude:
|
repo: nexus.khongisa.co.za/mngomalab/webapitest
|
||||||
- promote
|
tags: [ "${DRONE_BUILD_NUMBER}", "latest" ]
|
||||||
|
username:
|
||||||
|
from_secret: docker_username
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
|
||||||
---
|
# --- DEPLOY STAGE ---
|
||||||
kind: pipeline
|
- name: deploy-uat
|
||||||
type: docker
|
|
||||||
name: deploy-to-uat
|
|
||||||
|
|
||||||
depends_on:
|
|
||||||
- build-and-package
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: uat-deployment
|
|
||||||
image: appleboy/drone-ssh
|
image: appleboy/drone-ssh
|
||||||
settings:
|
settings:
|
||||||
host: { from_secret: ssh_host }
|
host:
|
||||||
username: { from_secret: ssh_user }
|
from_secret: ssh_host
|
||||||
password: { from_secret: ssh_password }
|
username:
|
||||||
|
from_secret: ssh_user
|
||||||
|
password:
|
||||||
|
from_secret: ssh_password
|
||||||
script:
|
script:
|
||||||
|
# Login to Nexus on the remote server
|
||||||
- echo $DOCKER_PASSWORD | docker login nexus.khongisa.co.za -u $DOCKER_USERNAME --password-stdin
|
- echo $DOCKER_PASSWORD | docker login nexus.khongisa.co.za -u $DOCKER_USERNAME --password-stdin
|
||||||
- docker pull nexus.khongisa.co.za/webapitest:latest
|
- docker pull nexus.khongisa.co.za/mngomalab/webapitest:latest
|
||||||
|
# Standard Linux cleanup
|
||||||
- docker stop webapi 2>/dev/null || true
|
- docker stop webapi 2>/dev/null || true
|
||||||
- docker rm 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
|
- docker run -d --name webapi --restart unless-stopped -e ASPNETCORE_ENVIRONMENT=Development -p 4000:8081 nexus.khongisa.co.za/mngomalab/webapitest:latest
|
||||||
environment:
|
environment:
|
||||||
DOCKER_USERNAME: { from_secret: docker_username }
|
DOCKER_USERNAME:
|
||||||
DOCKER_PASSWORD: { from_secret: docker_password }
|
from_secret: docker_username
|
||||||
|
DOCKER_PASSWORD:
|
||||||
|
from_secret: docker_password
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
event:
|
event:
|
||||||
- promote
|
exclude:
|
||||||
target:
|
- promote
|
||||||
- staging
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM nexus.khongisa.co.za/aspnet:10.0 AS final
|
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS final
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
USER app
|
USER app
|
||||||
|
|||||||
Reference in New Issue
Block a user