2024-08-30 16:52:15 +08:00
|
|
|
# .woodpecker.yml
|
|
|
|
steps:
|
2024-08-30 21:34:01 +08:00
|
|
|
- name: build
|
2024-08-30 17:11:37 +08:00
|
|
|
image: docker
|
2024-08-30 16:52:15 +08:00
|
|
|
when:
|
|
|
|
- branch: master
|
|
|
|
- event: push
|
|
|
|
commands:
|
2024-08-30 21:34:01 +08:00
|
|
|
- docker build . -t git.keannu1.duckdns.org/keannu125/drf_template
|
|
|
|
- echo "$REGISTRY_PASSWORD" | docker login git.keannu1.duckdns.org --password-stdin -u "$REGISTRY_USERNAME"
|
|
|
|
- docker push git.keannu1.duckdns.org/keannu125/drf_template
|
2024-08-30 17:11:37 +08:00
|
|
|
volumes:
|
|
|
|
- /var/run/docker.sock:/var/run/docker.sock
|
2024-08-30 21:34:01 +08:00
|
|
|
secrets: [REGISTRY_USERNAME, REGISTRY_PASSWORD]
|
|
|
|
- name: deploy
|
2024-08-30 17:11:37 +08:00
|
|
|
image: docker
|
2024-08-30 16:52:15 +08:00
|
|
|
when:
|
|
|
|
- branch: master
|
|
|
|
- event: push
|
|
|
|
commands:
|
|
|
|
- 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 root@10.0.10.4 '
|
2024-08-30 21:34:01 +08:00
|
|
|
cd "/mnt/nvme/files/docker projects/DRF-Template";
|
2024-08-30 16:52:15 +08:00
|
|
|
docker-compose down;
|
2024-08-30 21:34:01 +08:00
|
|
|
docker image rm git.keannu1.duckdns.org/keannu125/drf_template || true;
|
|
|
|
docker pull git.keannu1.duckdns.org/keannu125/drf_template:latest;
|
|
|
|
docker volume rm "git.keannu1.duckdns.org/keannu125/drf_template_db_data" || true;
|
|
|
|
docker compose up -f docker-compose.prod.yml -d;'
|
|
|
|
secrets: [SSH_KEY]
|