This commit is contained in:
326
.drone.yml
326
.drone.yml
@@ -4,37 +4,37 @@ name: code-quality
|
|||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
event:
|
event:
|
||||||
- push
|
- push
|
||||||
- pull_request
|
- pull_request
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: python-lint
|
- name: python-lint
|
||||||
image: python:3.11-slim
|
image: python:3.11-slim
|
||||||
commands:
|
commands:
|
||||||
- cd backend
|
- cd backend
|
||||||
- pip install flake8
|
- pip install flake8
|
||||||
- flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
- flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
||||||
|
|
||||||
- name: frontend-lint
|
- name: frontend-lint
|
||||||
image: node:20-alpine
|
image: node:20-alpine
|
||||||
commands:
|
commands:
|
||||||
- cd frontend
|
- cd frontend
|
||||||
- npm ci --silent
|
- npm ci --silent
|
||||||
- npm run lint || echo "ESLint warnings found"
|
- npm run lint || echo "ESLint warnings found"
|
||||||
|
|
||||||
- name: python-security
|
- name: python-security
|
||||||
image: python:3.11-slim
|
image: python:3.11-slim
|
||||||
commands:
|
commands:
|
||||||
- cd backend
|
- cd backend
|
||||||
- pip install safety
|
- pip install safety
|
||||||
- safety check --file=requirements.txt --exit-zero || echo "Security warnings found"
|
- safety check --file=requirements.txt --exit-zero || echo "Security warnings found"
|
||||||
|
|
||||||
- name: frontend-security
|
- name: frontend-security
|
||||||
image: node:20-alpine
|
image: node:20-alpine
|
||||||
commands:
|
commands:
|
||||||
- cd frontend
|
- cd frontend
|
||||||
- npm ci --silent
|
- npm ci --silent
|
||||||
- npm audit --audit-level=moderate || echo "Security warnings found"
|
- npm audit --audit-level=moderate || echo "Security warnings found"
|
||||||
|
|
||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
@@ -43,42 +43,42 @@ name: build-backend
|
|||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
branch:
|
branch:
|
||||||
- main
|
- main
|
||||||
- master
|
- master
|
||||||
- develop
|
- develop
|
||||||
event:
|
event:
|
||||||
- push
|
|
||||||
- tag
|
|
||||||
|
|
||||||
depends_on:
|
|
||||||
- code-quality
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: build-backend-image
|
|
||||||
image: plugins/docker
|
|
||||||
settings:
|
|
||||||
registry: registry.nevetime.ru
|
|
||||||
repo: registry.nevetime.ru/mc-panel-backend
|
|
||||||
tags:
|
|
||||||
- latest
|
|
||||||
- ${DRONE_COMMIT_SHA:0:8}
|
|
||||||
- ${DRONE_BRANCH}
|
|
||||||
auto_tag: true
|
|
||||||
dockerfile: backend/Dockerfile
|
|
||||||
context: backend
|
|
||||||
username:
|
|
||||||
from_secret: docker_username
|
|
||||||
password:
|
|
||||||
from_secret: docker_password
|
|
||||||
build_args:
|
|
||||||
- BUILD_DATE=${DRONE_BUILD_CREATED}
|
|
||||||
- VCS_REF=${DRONE_COMMIT_SHA}
|
|
||||||
- VERSION=${DRONE_TAG:-${DRONE_BRANCH}}
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
- push
|
- push
|
||||||
- tag
|
- tag
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- code-quality
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: build-backend-image
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
registry: registry.nevetime.ru
|
||||||
|
repo: registry.nevetime.ru/mc-panel-backend
|
||||||
|
tags:
|
||||||
|
- latest
|
||||||
|
- ${DRONE_COMMIT_SHA:0:8}
|
||||||
|
- ${DRONE_BRANCH}
|
||||||
|
auto_tag: true
|
||||||
|
dockerfile: backend/Dockerfile
|
||||||
|
context: backend
|
||||||
|
username:
|
||||||
|
from_secret: docker_username
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
build_args:
|
||||||
|
- BUILD_DATE=${DRONE_BUILD_CREATED}
|
||||||
|
- VCS_REF=${DRONE_COMMIT_SHA}
|
||||||
|
- VERSION=${DRONE_TAG:-${DRONE_BRANCH}}
|
||||||
|
when:
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
- tag
|
||||||
|
|
||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: docker
|
type: docker
|
||||||
@@ -86,43 +86,43 @@ name: build-frontend
|
|||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
branch:
|
branch:
|
||||||
- main
|
- main
|
||||||
- master
|
- master
|
||||||
- develop
|
- develop
|
||||||
event:
|
event:
|
||||||
- push
|
|
||||||
- tag
|
|
||||||
|
|
||||||
depends_on:
|
|
||||||
- code-quality
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: build-frontend-image
|
|
||||||
image: plugins/docker
|
|
||||||
settings:
|
|
||||||
registry: registry.nevetime.ru
|
|
||||||
repo: registry.nevetime.ru/mc-panel-frontend
|
|
||||||
tags:
|
|
||||||
- latest
|
|
||||||
- ${DRONE_COMMIT_SHA:0:8}
|
|
||||||
- ${DRONE_BRANCH}
|
|
||||||
auto_tag: true
|
|
||||||
dockerfile: frontend/Dockerfile
|
|
||||||
context: frontend
|
|
||||||
target: production
|
|
||||||
username:
|
|
||||||
from_secret: docker_username
|
|
||||||
password:
|
|
||||||
from_secret: docker_password
|
|
||||||
build_args:
|
|
||||||
- BUILD_DATE=${DRONE_BUILD_CREATED}
|
|
||||||
- VCS_REF=${DRONE_COMMIT_SHA}
|
|
||||||
- VERSION=${DRONE_TAG:-${DRONE_BRANCH}}
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
- push
|
- push
|
||||||
- tag
|
- tag
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- code-quality
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: build-frontend-image
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
registry: registry.nevetime.ru
|
||||||
|
repo: registry.nevetime.ru/mc-panel-frontend
|
||||||
|
tags:
|
||||||
|
- latest
|
||||||
|
- ${DRONE_COMMIT_SHA:0:8}
|
||||||
|
- ${DRONE_BRANCH}
|
||||||
|
auto_tag: true
|
||||||
|
dockerfile: frontend/Dockerfile
|
||||||
|
context: frontend
|
||||||
|
target: production
|
||||||
|
username:
|
||||||
|
from_secret: docker_username
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
build_args:
|
||||||
|
- BUILD_DATE=${DRONE_BUILD_CREATED}
|
||||||
|
- VCS_REF=${DRONE_COMMIT_SHA}
|
||||||
|
- VERSION=${DRONE_TAG:-${DRONE_BRANCH}}
|
||||||
|
when:
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
- tag
|
||||||
|
|
||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: docker
|
type: docker
|
||||||
@@ -130,42 +130,42 @@ name: build-monolith
|
|||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
branch:
|
branch:
|
||||||
- main
|
- main
|
||||||
- master
|
- master
|
||||||
- develop
|
- develop
|
||||||
event:
|
event:
|
||||||
- push
|
|
||||||
- tag
|
|
||||||
|
|
||||||
depends_on:
|
|
||||||
- code-quality
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: build-monolith-image
|
|
||||||
image: plugins/docker
|
|
||||||
settings:
|
|
||||||
registry: registry.nevetime.ru
|
|
||||||
repo: registry.nevetime.ru/mc-panel
|
|
||||||
tags:
|
|
||||||
- latest
|
|
||||||
- ${DRONE_COMMIT_SHA:0:8}
|
|
||||||
- ${DRONE_BRANCH}
|
|
||||||
auto_tag: true
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
context: .
|
|
||||||
username:
|
|
||||||
from_secret: docker_username
|
|
||||||
password:
|
|
||||||
from_secret: docker_password
|
|
||||||
build_args:
|
|
||||||
- BUILD_DATE=${DRONE_BUILD_CREATED}
|
|
||||||
- VCS_REF=${DRONE_COMMIT_SHA}
|
|
||||||
- VERSION=${DRONE_TAG:-${DRONE_BRANCH}}
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
- push
|
- push
|
||||||
- tag
|
- tag
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- code-quality
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: build-monolith-image
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
registry: registry.nevetime.ru
|
||||||
|
repo: registry.nevetime.ru/mc-panel
|
||||||
|
tags:
|
||||||
|
- latest
|
||||||
|
- ${DRONE_COMMIT_SHA:0:8}
|
||||||
|
- ${DRONE_BRANCH}
|
||||||
|
auto_tag: true
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
context: .
|
||||||
|
username:
|
||||||
|
from_secret: docker_username
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
build_args:
|
||||||
|
- BUILD_DATE=${DRONE_BUILD_CREATED}
|
||||||
|
- VCS_REF=${DRONE_COMMIT_SHA}
|
||||||
|
- VERSION=${DRONE_TAG:-${DRONE_BRANCH}}
|
||||||
|
when:
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
- tag
|
||||||
|
|
||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: docker
|
type: docker
|
||||||
@@ -173,31 +173,31 @@ name: deploy-staging
|
|||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
branch:
|
branch:
|
||||||
- develop
|
- develop
|
||||||
event:
|
event:
|
||||||
- push
|
- push
|
||||||
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- build-backend
|
- build-backend
|
||||||
- build-frontend
|
- build-frontend
|
||||||
- build-monolith
|
- build-monolith
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: deploy-separate-services
|
- name: deploy-separate-services
|
||||||
image: alpine:latest
|
image: alpine:latest
|
||||||
environment:
|
environment:
|
||||||
STAGING_HOST:
|
STAGING_HOST:
|
||||||
from_secret: staging_host
|
from_secret: staging_host
|
||||||
STAGING_USER:
|
STAGING_USER:
|
||||||
from_secret: staging_user
|
from_secret: staging_user
|
||||||
STAGING_KEY:
|
STAGING_KEY:
|
||||||
from_secret: staging_ssh_key
|
from_secret: staging_ssh_key
|
||||||
commands:
|
commands:
|
||||||
- apk add --no-cache openssh-client
|
- apk add --no-cache openssh-client
|
||||||
- echo "Deploying separate services to staging..."
|
- echo "Deploying separate services to staging..."
|
||||||
- echo "$STAGING_KEY" | base64 -d > /tmp/ssh_key
|
- echo "$STAGING_KEY" | base64 -d > /tmp/ssh_key
|
||||||
- chmod 600 /tmp/ssh_key
|
- chmod 600 /tmp/ssh_key
|
||||||
- ssh -o StrictHostKeyChecking=no -i /tmp/ssh_key $STAGING_USER@$STAGING_HOST "docker pull registry.nevetime.ru/mc-panel-backend:${DRONE_COMMIT_SHA:0:8} && docker pull registry.nevetime.ru/mc-panel-frontend:${DRONE_COMMIT_SHA:0:8}"
|
- ssh -o StrictHostKeyChecking=no -i /tmp/ssh_key $STAGING_USER@$STAGING_HOST "docker pull registry.nevetime.ru/mc-panel-backend:${DRONE_COMMIT_SHA:0:8} && docker pull registry.nevetime.ru/mc-panel-frontend:${DRONE_COMMIT_SHA:0:8}"
|
||||||
|
|
||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
@@ -206,28 +206,28 @@ name: deploy-production
|
|||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
ref:
|
ref:
|
||||||
- refs/tags/v*
|
- refs/tags/v*
|
||||||
event:
|
event:
|
||||||
- tag
|
- tag
|
||||||
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- build-backend
|
- build-backend
|
||||||
- build-frontend
|
- build-frontend
|
||||||
- build-monolith
|
- build-monolith
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: deploy-separate-services
|
- name: deploy-separate-services
|
||||||
image: alpine:latest
|
image: alpine:latest
|
||||||
environment:
|
environment:
|
||||||
PROD_HOST:
|
PROD_HOST:
|
||||||
from_secret: production_host
|
from_secret: production_host
|
||||||
PROD_USER:
|
PROD_USER:
|
||||||
from_secret: production_user
|
from_secret: production_user
|
||||||
PROD_KEY:
|
PROD_KEY:
|
||||||
from_secret: production_ssh_key
|
from_secret: production_ssh_key
|
||||||
commands:
|
commands:
|
||||||
- apk add --no-cache openssh-client
|
- apk add --no-cache openssh-client
|
||||||
- echo "Deploying separate services to production..."
|
- echo "Deploying separate services to production..."
|
||||||
- echo "$PROD_KEY" | base64 -d > /tmp/ssh_key
|
- echo "$PROD_KEY" | base64 -d > /tmp/ssh_key
|
||||||
- chmod 600 /tmp/ssh_key
|
- chmod 600 /tmp/ssh_key
|
||||||
- ssh -o StrictHostKeyChecking=no -i /tmp/ssh_key $PROD_USER@$PROD_HOST "docker pull registry.nevetime.ru/mc-panel-backend:${DRONE_TAG} && docker pull registry.nevetime.ru/mc-panel-frontend:${DRONE_TAG}"
|
- ssh -o StrictHostKeyChecking=no -i /tmp/ssh_key $PROD_USER@$PROD_HOST "docker pull registry.nevetime.ru/mc-panel-backend:${DRONE_TAG} && docker pull registry.nevetime.ru/mc-panel-frontend:${DRONE_TAG}"
|
||||||
Reference in New Issue
Block a user