feat: Add Woodpecker CI/CD pipeline for automated deployments and update Docker Compose to pull images from Gitea registry with .env file integration.
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
45
.woodpecker.yml
Normal file
45
.woodpecker.yml
Normal file
@@ -0,0 +1,45 @@
|
||||
pipeline:
|
||||
# 1. Build & Push Image ke Gitea Container Registry
|
||||
# Kita menggunakan plugin/docker agar Woodpecker melakukan build Dockerfile Anda
|
||||
build-and-push:
|
||||
image: plugins/docker
|
||||
settings:
|
||||
# URL Gitea Anda
|
||||
registry: git.exavolt.web.id
|
||||
# Format: git.exavolt.web.id/username/repo-name
|
||||
repo: git.exavolt.web.id/fikri/fullstack-portfolio
|
||||
username:
|
||||
from_secret: gitea_user
|
||||
password:
|
||||
from_secret: gitea_token
|
||||
dockerfile: Dockerfile
|
||||
# Menggunakan cache agar build berikutnya lebih cepat
|
||||
use_cache: true
|
||||
when:
|
||||
branch: main
|
||||
event: push
|
||||
|
||||
# 2. Deploy ke VPS via SSH
|
||||
deploy:
|
||||
image: appleboy/drone-ssh
|
||||
settings:
|
||||
host: 103.197.190.44
|
||||
username: root
|
||||
key:
|
||||
from_secret: ssh_key
|
||||
port: 22
|
||||
script:
|
||||
# Pindah ke folder tempat docker-compose.yml berada di VPS
|
||||
- cd ~/portfolio
|
||||
# Login ke Gitea Registry (diperlukan untuk pull image)
|
||||
- echo $GITEA_TOKEN | docker login git.exavolt.web.id -u $GITEA_USER --password-stdin
|
||||
# Tarik image terbaru yang baru saja di-build
|
||||
- docker compose pull
|
||||
# Restart container dengan image baru
|
||||
- docker compose up -d --remove-orphans
|
||||
# Membersihkan image lama yang tidak terpakai (dangling)
|
||||
- docker image prune -f
|
||||
secrets: [ gitea_user, gitea_token, ssh_key ]
|
||||
when:
|
||||
branch: main
|
||||
event: push
|
||||
Reference in New Issue
Block a user