memo_docker 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. #!/bin/sh
  2. # $Id: memo_docker,v 1.17 2022/04/04 14:46:21 gilles Exp gilles $
  3. echo imapsync_docker_timestamp_dockerfile
  4. imapsync_docker_timestamp_dockerfile()
  5. {
  6. DATE_CURRENT=`date +%Y_%m_%d_%H_%M_%S`
  7. echo $DATE_CURRENT
  8. sed -i -e "/just_a_comment_to_force_update/s/comment_to_force_update.*/comment_to_force_update $DATE_CURRENT/" Dockerfile
  9. ci -l -f -m"Changing timestamp to $DATE_CURRENT with imapsync_docker_timestamp_dockerfile" Dockerfile
  10. }
  11. echo imapsync_docker_build
  12. imapsync_docker_build()
  13. {
  14. docker build -t gilleslamiral/imapsync . \
  15. && imapsync_docker_add_tag_version && echo Build SUCCEEDED || echo Build FAILED
  16. }
  17. echo imapsync_docker_version
  18. imapsync_docker_version()
  19. {
  20. docker run gilleslamiral/imapsync imapsync --version
  21. }
  22. echo imapsync_local_docker_version
  23. imapsync_local_docker_version()
  24. {
  25. docker run gilleslamiral/imapsync /imapsync --version
  26. }
  27. echo imapsync_docker_add_tag_version
  28. imapsync_docker_add_tag_version()
  29. {
  30. docker images gilleslamiral/imapsync
  31. echo
  32. version=`imapsync_docker_version`
  33. echo $version
  34. docker tag gilleslamiral/imapsync:latest gilleslamiral/imapsync:$version
  35. docker images gilleslamiral/imapsync
  36. }
  37. echo imapsync_docker_testslive
  38. imapsync_docker_testslive()
  39. {
  40. echo docker run gilleslamiral/imapsync imapsync --testslive "$@"
  41. docker run gilleslamiral/imapsync imapsync --testslive "$@"
  42. }
  43. echo imapsync_docker_testslive6
  44. imapsync_docker_testslive6()
  45. {
  46. echo docker run gilleslamiral/imapsync imapsync --testslive6 "$@"
  47. docker run gilleslamiral/imapsync imapsync --testslive6 "$@"
  48. }
  49. echo imapsync_docker_tests
  50. imapsync_docker_tests()
  51. {
  52. echo docker run gilleslamiral/imapsync imapsync --tests
  53. docker run gilleslamiral/imapsync imapsync --tests
  54. }
  55. echo imapsync_docker_envfile
  56. imapsync_docker_envfile()
  57. {
  58. docker run --env-file ./secret.txt gilleslamiral/imapsync imapsync \
  59. --host1 test1.lamiral.info --user1 test1 \
  60. --host2 test2.lamiral.info --user2 test2 --justlogin
  61. }
  62. echo docker_delete_all_images
  63. docker_delete_all_images()
  64. {
  65. docker rm `docker ps -a -q`
  66. docker rmi `docker images -q`
  67. }
  68. echo docker_system_prune
  69. docker_system_prune()
  70. {
  71. docker system prune
  72. }
  73. echo docker_delete_dandling_images
  74. docker_delete_dandling_images()
  75. {
  76. docker images
  77. dandling_images=`docker images -f dangling=true -q`
  78. exited_containers=`docker ps -a -f status=exited -q`
  79. test -n "$exited_containers" && docker rm $exited_containers
  80. test -n "$dandling_images" && docker rmi $dandling_images
  81. docker images
  82. }
  83. echo imapsync_docker_rebuild_from_scratch
  84. imapsync_docker_rebuild_from_scratch()
  85. {
  86. delete_all_images
  87. docker images
  88. imapsync_docker_build
  89. }
  90. echo is_release_number
  91. is_release_number()
  92. {
  93. echo "$1" | perl -pe 'm/^\d\.\d+$/ || exit 1'
  94. }
  95. echo imapsync_docker_upload
  96. imapsync_docker_upload()
  97. {
  98. version=`imapsync_docker_version`
  99. version_local=`imapsync_local_docker_version`
  100. # upload only after successful tests
  101. set -x \
  102. && is_release_number "$version" \
  103. && is_release_number "$version_local" \
  104. && test "$version" = "$version_local" \
  105. && rcsdiff imapsync Dockerfile memo_docker \
  106. && imapsync_docker_testslive \
  107. && imapsync_docker_tests \
  108. && docker run gilleslamiral/imapsync true \
  109. && docker run gilleslamiral/imapsync diff /imapsync /usr/bin/imapsync \
  110. && docker login --username=gilleslamiral --password=`cat $HOME/var/pass/secret.docker` \
  111. && docker push gilleslamiral/imapsync:latest \
  112. && docker push gilleslamiral/imapsync:$version \
  113. && set +x && echo imapsync push SUCCEEDED || echo imapsync push FAILED
  114. set +x
  115. }