Taskfile to universal task runner który pozwala zdefiniować zadania raz i uruchamiać je wszędzie:
┌────────────────────────────────────────────────────────┐
│ Taskfile.yml │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Variables │ │Environments │ │ Platforms │ │
│ │ (zmienne) │ │ (envs) │ │ │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ ┌───────────────────────────────────────────────────┐ │
│ │ Tasks │ │
│ │ - init - deploy - ci-generate │ │
│ │ - build - validate - test │ │
│ │ - push - status - logs │ │
│ └───────────────────────────────────────────────────┘ │
└────────────────────────────────────────────────────────┘
│
┌───────────────┼───────────────┐
▼ ▼ ▼
┌────────────┐ ┌────────────┐ ┌────────────┐
│ Local │ │ VPS │ │ CI/CD │
│ Docker │ │ SSH │ │ GitHub │
└────────────┘ └────────────┘ └────────────┘
# Generuj pliki dla różnych platform CI/CD
taskfile run ci-generate
# Powstaną:
# .github/workflows/deploy.yml (GitHub Actions)
# .gitlab-ci.yml (GitLab CI)
Jak to działa:
Task ci-generate tworzy gotowe konfiguracje które:
taskfile run deploy)# Walidacja w izolowanym kontenerze
taskfile run validate-deploy
# Walidacja w VM (Vagrant)
taskfile run validate-vm
# Pełna walidacja (Docker + testy)
taskfile run validate-all
# Sprawdzenie wymagań przed deploy
taskfile run preflight
Jak to działa:
validate-deploy:
docker build -t app-validatecurl http://localhost:9999/healthvalidate-vm:
http://localhost:9999# Setup VPS (instalacja Podman, firewall)
taskfile --env prod run vps-setup
# Deploy web
taskfile --env prod --platform web run deploy
# Deploy desktop + web
taskfile --env prod run deploy-all
Jak to działa:
Twoja maszyna VPS (przez SSH)
│ │
├── ssh VPS_IP ────────►│
│ │
├── docker build │
├── docker push ───────►│ podman pull
│ │
└── ssh restart ───────►│ podman run
# Tworzy .env z .env.example
taskfile run init
# Sprawdza konfigurację
taskfile run env-check
# 1. Clone repo
git clone https://github.com/example/app.git
cd app
# 2. Init (stworzy .env)
taskfile run init
# 3. Edytuj .env
nano .env
# VPS_IP=123.456.789.012
# 4. Walidacja
taskfile run validate-all
# 5. Deploy
taskfile --env prod run deploy-all
# Lokalny development
taskfile run dev # Start lokalnie
taskfile run test # Uruchom testy
taskfile run preflight # Sprawdź czy wszystko OK
# Generuj CI/CD
taskfile run ci-generate
git add .github/workflows/
git commit -m "Add CI/CD"
# Deploy na VPS
taskfile --env prod run deploy-all
GitHub Actions (auto-generowany):
name: Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: pip install taskfile
- run: taskfile --env prod run deploy
env:
VPS_IP: $
GitLab CI (auto-generowany):
stages:
- deploy
deploy:
stage: deploy
script:
- pip install taskfile
- taskfile --env prod run deploy
only:
- main
| Funkcja | Opis | Komenda |
|---|---|---|
| Multi-env | local/prod z różnymi konfiguracjami | --env prod |
| Multi-platform | web/desktop z różnymi deployami | --platform web |
| Variables | Kaskadowe zmienne: global → env → platform → CLI | --var KEY=value |
| @remote | Prefix dla komend SSH | @remote podman ps |
| deps | Zależności między taskami | deps: [init, build] |
| condition | Warunkowe wykonanie | condition: "test -f file" |
| Dry-run | Podgląd bez wykonania | --dry-run |
variables:
# Global (domyślne dla wszystkich)
APP_NAME: my-app
TAG: latest
environments:
local:
variables:
DOMAIN: localhost # Nadpisuje dla local
prod:
variables:
DOMAIN: ${VPS_IP} # Nadpisuje dla prod
# CLI nadpisuje wszystko:
# taskfile --env prod --var TAG=v1.0.0 run deploy
--env i --platform@remote → wykonuje przez SSHdeps: [] → uruchamia zależności pierwszeignore_errors: true → kontynuuje mimo błędutaskfile run validate-deploy
Co się dzieje:
Docker Build ──► Docker Run ──► Health Check ──► Cleanup
│ │ │ │
30s-2m Start app curl /health docker rm
taskfile run validate-vm
Co się dzieje:
Vagrant Up ──► Install Podman ──► Deploy ──► Test ──► Destroy
│ │ │ │ │
2-5 min apt-get Same as curl vagrant
prod /health destroy
# Dodaj staging do Taskfile.yml
environments:
staging:
ssh_host: staging.example.com
container_runtime: podman
taskfile --env staging run deploy
# W task ci-generate
ci-generate:
cmds:
- |
# Jenkins
cat > Jenkinsfile << 'EOF'
pipeline {
agent any
stages {
stage('Deploy') {
steps {
sh 'pip install taskfile'
sh 'taskfile --env prod run deploy'
}
}
}
}
EOF
environments:
staging:
desc: Staging environment
ssh_host: ${STAGING_IP}
ssh_user: deploy
container_runtime: podman
variables:
DOMAIN: staging.example.com
taskfile --env staging run deploy
Taskfile pozwala:
Minimalny setup:
echo "VPS_IP=123.456.789.012" > .env
taskfile --env prod run deploy-all