mirror of
https://github.com/lemeow125/Service_Queue.git
synced 2025-09-20 14:33:02 +08:00
Update .yml files and README.md
This commit is contained in:
parent
6b999b8298
commit
30eea7e784
4 changed files with 136 additions and 5 deletions
54
.woodpecker/,deploy.yml
Normal file
54
.woodpecker/,deploy.yml
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
# Deployment YML for Woodpecker CI/CD
|
||||||
|
# Ephemeral volumes - Data is not persisted across deployments (i.e. database volume)
|
||||||
|
# Remove line 29 for persistent volumes
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: deploy
|
||||||
|
image: alpine:3.20
|
||||||
|
environment:
|
||||||
|
SSH_HOST:
|
||||||
|
from_secret: SSH_HOST
|
||||||
|
PROJECT_DIRECTORY:
|
||||||
|
from_secret: PROJECT_DIRECTORY
|
||||||
|
SSH_KEY:
|
||||||
|
from_secret: SSH_KEY
|
||||||
|
REGISTRY_IMAGE_TAG:
|
||||||
|
from_secret: REGISTRY_IMAGE_TAG
|
||||||
|
DOCKER_VOLUME_DB:
|
||||||
|
from_secret: DOCKER_VOLUME_DB
|
||||||
|
commands:
|
||||||
|
- apk add openssh
|
||||||
|
- mkdir -p /root/.ssh/
|
||||||
|
- echo "$SSH_KEY" | tr -d '\r' > /root/.ssh/id_rsa
|
||||||
|
- chmod 600 /root/.ssh/id_rsa
|
||||||
|
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > /root/.ssh/config
|
||||||
|
- ssh "$SSH_HOST" "
|
||||||
|
cd "$PROJECT_DIRECTORY";
|
||||||
|
docker-compose down;
|
||||||
|
docker image rm "$REGISTRY_IMAGE_TAG" || true;
|
||||||
|
docker volume rm "$DOCKER_VOLUME_DB" || true;
|
||||||
|
wget -O "$DOCKER_COMPOSE_URL" docker-compose.yml;
|
||||||
|
docker pull "$REGISTRY_IMAGE_TAG";
|
||||||
|
docker-compose up -d;
|
||||||
|
docker image prune -af;"
|
||||||
|
- name: discord
|
||||||
|
image: appleboy/drone-discord
|
||||||
|
settings:
|
||||||
|
webhook_id:
|
||||||
|
from_secret: DISCORD_WEBHOOK_ID
|
||||||
|
webhook_token:
|
||||||
|
from_secret: DISCORD_WEBHOOK_TOKEN
|
||||||
|
message: >
|
||||||
|
{{#success build.status}}
|
||||||
|
{{repo.name}} deployment #{{build.number}} {{build.status}}
|
||||||
|
{{/success}}
|
||||||
|
depends_on: deploy
|
||||||
|
|
||||||
|
when:
|
||||||
|
- branch: master
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
- manual
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- build
|
41
.woodpecker/.build.yml
Normal file
41
.woodpecker/.build.yml
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
# Build YML for Woodpecker CI/CD
|
||||||
|
|
||||||
|
labels:
|
||||||
|
platform: linux/amd64
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: build
|
||||||
|
image: docker
|
||||||
|
environment:
|
||||||
|
FORGEJO_REGISTRY_URL:
|
||||||
|
from_secret: FORGEJO_REGISTRY_URL
|
||||||
|
FORGEJO_REGISTRY_USERNAME:
|
||||||
|
from_secret: FORGEJO_REGISTRY_USERNAME
|
||||||
|
FORGEJO_REGISTRY_PASSWORD:
|
||||||
|
from_secret: FORGEJO_REGISTRY_PASSWORD
|
||||||
|
REGISTRY_IMAGE_TAG:
|
||||||
|
from_secret: REGISTRY_IMAGE_TAG
|
||||||
|
commands:
|
||||||
|
- docker build -t "$REGISTRY_IMAGE_TAG" .
|
||||||
|
- echo "$FORGEJO_REGISTRY_PASSWORD" | docker login "$FORGEJO_REGISTRY_URL" --password-stdin -u "$FORGEJO_REGISTRY_USERNAME"
|
||||||
|
- docker push "$REGISTRY_IMAGE_TAG"
|
||||||
|
volumes:
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
- name: discord
|
||||||
|
image: appleboy/drone-discord
|
||||||
|
settings:
|
||||||
|
webhook_id:
|
||||||
|
from_secret: DISCORD_WEBHOOK_ID
|
||||||
|
webhook_token:
|
||||||
|
from_secret: DISCORD_WEBHOOK_TOKEN
|
||||||
|
message: >
|
||||||
|
{{#success build.status}}
|
||||||
|
{{repo.name}} build #{{build.number}} {{build.status}}
|
||||||
|
{{/success}}
|
||||||
|
depends_on: build
|
||||||
|
|
||||||
|
when:
|
||||||
|
- branch: master
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
- manual
|
|
@ -1,3 +1,6 @@
|
||||||
|
# Deployment file for Woodpecker CI/CD
|
||||||
|
# No volumes - Suited for deployments without local databases (i.e. external PostgreSQL instance)
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: deploy
|
- name: deploy
|
||||||
image: alpine:3.20
|
image: alpine:3.20
|
||||||
|
@ -20,15 +23,17 @@ steps:
|
||||||
cd "$PROJECT_DIRECTORY";
|
cd "$PROJECT_DIRECTORY";
|
||||||
docker-compose down;
|
docker-compose down;
|
||||||
docker image rm "$REGISTRY_IMAGE_TAG" || true;
|
docker image rm "$REGISTRY_IMAGE_TAG" || true;
|
||||||
git restore . && git pull origin "$CI_COMMIT_BRANCH";
|
wget -O "$DOCKER_COMPOSE_URL" docker-compose.yml;
|
||||||
docker-compose up -d;"
|
docker pull "$REGISTRY_IMAGE_TAG";
|
||||||
|
docker-compose up -d;
|
||||||
|
docker image prune -af;"
|
||||||
- name: discord
|
- name: discord
|
||||||
image: appleboy/drone-discord
|
image: appleboy/drone-discord
|
||||||
settings:
|
settings:
|
||||||
webhook_id:
|
webhook_id:
|
||||||
from_secret: SERVICE_QUEUE_DISCORD_WEBHOOK_ID
|
from_secret: DISCORD_WEBHOOK_ID
|
||||||
webhook_token:
|
webhook_token:
|
||||||
from_secret: SERVICE_QUEUE_DISCORD_WEBHOOK_TOKEN
|
from_secret: DISCORD_WEBHOOK_TOKEN
|
||||||
message: >
|
message: >
|
||||||
{{#success build.status}}
|
{{#success build.status}}
|
||||||
{{repo.name}} deployment #{{build.number}} {{build.status}}
|
{{repo.name}} deployment #{{build.number}} {{build.status}}
|
||||||
|
@ -36,7 +41,10 @@ steps:
|
||||||
depends_on: deploy
|
depends_on: deploy
|
||||||
|
|
||||||
when:
|
when:
|
||||||
- branch: main # Update branch name accordingly
|
- branch: master
|
||||||
event:
|
event:
|
||||||
- push
|
- push
|
||||||
- manual
|
- manual
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- build
|
28
README.md
28
README.md
|
@ -1,3 +1,31 @@
|
||||||
# Service Queue Templates
|
# Service Queue Templates
|
||||||
|
|
||||||
This repository contains a collection of templates tailored for DevOps practices designed to assist with Service Queue deployments.
|
This repository contains a collection of templates tailored for DevOps practices designed to assist with Service Queue deployments.
|
||||||
|
|
||||||
|
## `build.yml` Environment Variables
|
||||||
|
|
||||||
|
| Variable Name | Description | Value Value |
|
||||||
|
|----------------------------|--------------------------------------------------|----------------------------------------------------|
|
||||||
|
| `FORGEJO_REGISTRY_URL` | Artifact registry to push built image to | `git.06222001.xyz` |
|
||||||
|
| `FORGEJO_REGISTRY_USERNAME`| Credentials used to push to the image registry | `N/A (redacted)` |
|
||||||
|
| `FORGEJO_REGISTRY_PASSWORD`| Credentials used to push to the image registry | `N/A (redacted)` |
|
||||||
|
| `REGISTRY_IMAGE_TAG` | Docker image container tag to push to registry | `git.06222001.xyz/keannu125/drf_template:latest` |
|
||||||
|
| `DISCORD_WEBHOOK_ID` | Discord Webhook ID used for Build Status Updates | `N/A (redacted)` |
|
||||||
|
|
||||||
|
## `deploy.yml` Environment Variables
|
||||||
|
|
||||||
|
| Variable Name | Description | Value |
|
||||||
|
|----------------------|-----------------------------------------------------|--------------------------------------|
|
||||||
|
| `SSH_HOST` | SSH host for deployment | `N/A (redacted)` |
|
||||||
|
| `PROJECT_DIRECTORY` | Directory on remote host for deployment | `/mnt/nvme/files/docker projects/drf_template` |
|
||||||
|
| `SSH_KEY` | Private SSH key for authentication | `N/A (redacted)` |
|
||||||
|
| `REGISTRY_IMAGE_TAG` | Docker image tag to deploy | `git.06222001.xyz/keannu125/drf_template:latest` |
|
||||||
|
| `DOCKER_VOLUME_DB` | Docker volume name for the database | `drf_template_db_data` |
|
||||||
|
| `DOCKER_COMPOSE_URL` | URL to fetch docker-compose.yml | `https://raw.githubusercontent.com/lemeow125/DRF_Template/refs/heads/master/docker-compose.prod.yml` |
|
||||||
|
| `DISCORD_WEBHOOK_ID` | Discord Webhook ID for deployment notifications | `N/A (redacted)` |
|
||||||
|
| `DISCORD_WEBHOOK_TOKEN` | Discord Webhook Token for deployment notifications | `N/A (redacted)` |
|
||||||
|
|
||||||
|
> **Note:**
|
||||||
|
> Actual values may differ based on your pipeline configuration.
|
||||||
|
> Usage of `.deploy_ephemeral.yml` does not require `DOCKER_VOLUME_DB`
|
||||||
|
> For more information, consult your Woodpecker CI/CD maintainer.
|
Loading…
Add table
Add a link
Reference in a new issue