File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
docs/working-notes/temp-code Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change
1
+ # if pull and if id1 !== id2
2
+
3
+ ssh $REMOTE_HOST " cd $REMOTE_PATH && \
4
+
5
+ # Try to pull the new image, exit early if it fails
6
+ docker pull $IMAGE_NAME_WITH_TAG || { echo 'Docker pull failed, aborting.'; exit 1; } && \
7
+
8
+ # Get the image ID of the current image
9
+ OLD_IMAGE_ID=\$ (docker images -q $IMAGE_NAME_WITH_TAG ) && \
10
+
11
+ # Get the newly pulled image ID
12
+ NEW_IMAGE_ID=\$ (docker images -q $IMAGE_NAME_WITH_TAG ) && \
13
+
14
+ # Compare old and new image IDs, exit if they are the same
15
+ if [ \"\$ OLD_IMAGE_ID\" = \"\$ NEW_IMAGE_ID\" ]; then \
16
+ echo 'Image is already up to date. Exiting.'; \
17
+ exit 0; \
18
+ fi && \
19
+
20
+ # Stop the running containers
21
+ docker compose down && \
22
+
23
+ # Remove the old image if it exists
24
+ [ -n \"\$ OLD_IMAGE_ID\" ] && docker image rm \$ OLD_IMAGE_ID || true && \
25
+
26
+ # Bring up the containers with the new image
27
+ docker compose up -d"
You can’t perform that action at this time.
0 commit comments