68 lines
2.2 KiB
YAML
68 lines
2.2 KiB
YAML
# Woodpecker CI Pipeline for Soleprint
|
|
# Showcases custom build step: generates deployable code from templates
|
|
|
|
steps:
|
|
# Custom step: Generate deployable code from soleprint templates
|
|
# build.py assembles the soleprint instance for a specific config (amar)
|
|
generate:
|
|
image: python:3.11-slim
|
|
commands:
|
|
- pip install pyyaml jinja2
|
|
- python build.py dev --cfg amar
|
|
- ls -la gen/
|
|
|
|
# Build Docker image from generated code
|
|
build:
|
|
image: docker:24-dind
|
|
commands:
|
|
- echo "$REGISTRY_PASSWORD" | docker login -u "$REGISTRY_USER" --password-stdin registry.mcrn.ar
|
|
- cd gen
|
|
- docker build -t registry.mcrn.ar/soleprint:${CI_COMMIT_SHA:0:7} .
|
|
- docker tag registry.mcrn.ar/soleprint:${CI_COMMIT_SHA:0:7} registry.mcrn.ar/soleprint:latest
|
|
secrets: [registry_user, registry_password]
|
|
volumes:
|
|
- /var/run/docker.sock:/var/run/docker.sock
|
|
when:
|
|
event: push
|
|
branch: main
|
|
|
|
# Push to registry
|
|
push:
|
|
image: docker:24-dind
|
|
commands:
|
|
- echo "$REGISTRY_PASSWORD" | docker login -u "$REGISTRY_USER" --password-stdin registry.mcrn.ar
|
|
- docker push registry.mcrn.ar/soleprint:${CI_COMMIT_SHA:0:7}
|
|
- docker push registry.mcrn.ar/soleprint:latest
|
|
secrets: [registry_user, registry_password]
|
|
volumes:
|
|
- /var/run/docker.sock:/var/run/docker.sock
|
|
when:
|
|
event: push
|
|
branch: main
|
|
|
|
# Deploy to server
|
|
deploy:
|
|
image: appleboy/drone-ssh
|
|
settings:
|
|
host: mcrn.ar
|
|
username: mariano
|
|
key:
|
|
from_secret: deploy_key
|
|
script:
|
|
- echo "$REGISTRY_PASSWORD" | docker login -u "$REGISTRY_USER" --password-stdin registry.mcrn.ar
|
|
- docker network create mainroom_default 2>/dev/null || true
|
|
- cd ~/soleprint && git pull origin main
|
|
- cd ~/soleprint/gen
|
|
- |
|
|
if [ ! -f .env ]; then
|
|
echo "DEPLOYMENT_NAME=soleprint" > .env
|
|
echo "SOLEPRINT_PORT=12000" >> .env
|
|
fi
|
|
- docker pull registry.mcrn.ar/soleprint:latest
|
|
- docker compose down || true
|
|
- docker compose up -d
|
|
envs_from_secrets: [registry_user, registry_password]
|
|
when:
|
|
event: push
|
|
branch: main
|