Compare commits
15 Commits
a4766c3d48
...
test
| Author | SHA1 | Date | |
|---|---|---|---|
| e26c79a9d7 | |||
| ae1440fce3 | |||
| b58b5777fd | |||
| 83dfdc2cc3 | |||
| bbdb27b116 | |||
| 1da1328870 | |||
| 3b5ca4f5b0 | |||
| 1526648d9a | |||
| d1f723c135 | |||
| 423281d071 | |||
| 44fbc613a3 | |||
| a922531f50 | |||
| 9acebb67fe | |||
| e140319a05 | |||
| 3752da6ebe |
83
.drone.yml
83
.drone.yml
@@ -1,83 +1,68 @@
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: cicd-pipeline
|
||||
|
||||
# Let Drone handle the clone automatically; it's faster and cleaner.
|
||||
clone:
|
||||
depth: 1
|
||||
name: build-and-package
|
||||
|
||||
steps:
|
||||
- name: build-test-publish
|
||||
image: nexus.khongisa.co.za/mcr.microsoft.com/dotnet/sdk:10.0
|
||||
image: nexus.khongisa.co.za/sdk:10.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
|
||||
|
||||
# --- PACKAGE STAGE ---
|
||||
# We build the image locally first so we can scan it BEFORE pushing
|
||||
- name: docker-build
|
||||
- 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
|
||||
# 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: docker-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
|
||||
username: { from_secret: docker_username }
|
||||
password: { from_secret: docker_password }
|
||||
|
||||
- name: vulnerability-scan
|
||||
image: aquasec/trivy:0.50.1
|
||||
environment:
|
||||
# Trivy needs these to pull the image from your Nexus to scan it
|
||||
TRIVY_USERNAME:
|
||||
from_secret: docker_username
|
||||
TRIVY_PASSWORD:
|
||||
from_secret: docker_password
|
||||
TRIVY_USERNAME: { from_secret: docker_username }
|
||||
TRIVY_PASSWORD: { from_secret: docker_password }
|
||||
commands:
|
||||
- trivy image --exit-code 1 --severity CRITICAL nexus.khongisa.co.za/webapitest:${DRONE_BUILD_NUMBER}
|
||||
- trivy image --image-src remote --exit-code 1 --severity CRITICAL nexus.khongisa.co.za/webapitest:${DRONE_BUILD_NUMBER}
|
||||
|
||||
# --- DEPLOY STAGE ---
|
||||
- name: deploy-uat
|
||||
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
|
||||
host: { from_secret: ssh_host }
|
||||
username: { from_secret: ssh_user }
|
||||
password: { from_secret: ssh_password }
|
||||
script:
|
||||
# Login to Nexus on the remote server
|
||||
- echo $DOCKER_PASSWORD | docker login nexus.khongisa.co.za -u $DOCKER_USERNAME --password-stdin
|
||||
- docker pull nexus.khongisa.co.za/webapitest:latest
|
||||
# Standard Linux cleanup
|
||||
- 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
|
||||
DOCKER_USERNAME: { from_secret: docker_username }
|
||||
DOCKER_PASSWORD: { from_secret: docker_password }
|
||||
|
||||
trigger:
|
||||
event:
|
||||
exclude:
|
||||
- promote
|
||||
- promote
|
||||
target:
|
||||
- staging
|
||||
Reference in New Issue
Block a user