Deploy workflow: commit-id image tags, guarded deploy.sh, opt-in prune

- Makefile builds from 'git archive HEAD' (stale-remote-HEAD impossible):
  tags registry.tanshu.com/mozimo:<short-commit> + :main; build-check target
  verifies both architectures without pushing
- deploy.sh: refuses dirty tracked tree / HEAD != origin/main (--force to
  bypass), ff-only pull, passes the commit as image_tag to ansible,
  --prune flag for opt-in image cleanup
- ansible: docker_image uses image_tag extra-var (falls back to tag),
  prune task keeps the 3 newest mozimo images, mozimo-repo only
This commit is contained in:
2026-09-06 13:21:16 +05:30
parent 424a2b016a
commit 134f0b0a7a
4 changed files with 73 additions and 16 deletions
+7
View File
@@ -31,3 +31,10 @@
- "{{ host_directory }}/pb_data:/app/pb_data"
networks:
- name: "{{ docker_network }}"
- name: Prune old mozimo images, keep newest 3 (opt-in via ./deploy.sh --prune)
ansible.builtin.shell: >
docker images "registry.tanshu.com/mozimo" --format "{{.ID}}" | tail -n +4 | xargs -r docker rmi
when: mozimo_image_prune | default(false) | bool
failed_when: false
changed_when: true
+3 -1
View File
@@ -12,7 +12,9 @@ host: "staging.mozimo.in"
docker_network: "{{ title }}_net"
docker_image: "{{ registry }}/{{ title }}:{{ tag }}"
# image tag: deploy.sh passes -e image_tag=<commit>; "tag" is the fallback
# when running the playbook by hand — rollback = -e image_tag=<older-commit>
docker_image: "{{ registry }}/{{ title }}:{{ image_tag | default(tag) }}"
docker_container: "{{ title }}-staging"
docker_port: 3000