@@ -63,6 +63,21 @@ calc_sha()
6363 sha256sum " $1 " 2> /dev/null | awk ' {print $1}'
6464}
6565
66+ # Calculate a combined SHA256 over the container script and its
67+ # optional env file. Environment variables are stored separately
68+ # from the script, so both must be included in the checksum to
69+ # detect configuration changes such as added/changed env vars.
70+ calc_config_sha ()
71+ {
72+ _envfile=" /run/containers/args/${name} .env"
73+
74+ if [ -f " $_envfile " ]; then
75+ cat " $1 " " $_envfile " | sha256sum | awk ' {print $1}'
76+ else
77+ calc_sha " $1 "
78+ fi
79+ }
80+
6681# Check image transport, return 0 if remote, 1 if local
6782is_remote ()
6883{
@@ -124,7 +139,7 @@ is_uptodate()
124139 # If SHA matches, check container instance
125140 if [ " $stored_sha " = " $current_sha " ]; then
126141 if podman container exists " $name " ; then
127- config_sha=$( calc_sha " $script " )
142+ config_sha=$( calc_config_sha " $script " )
128143 container_sha=$( podman inspect " $name " --format ' {{index .Config.Labels "config-sha256"}}' 2> /dev/null)
129144 container_img_sha=$( podman inspect " $name " --format ' {{index .Config.Labels "meta-image-sha256"}}' 2> /dev/null)
130145
@@ -143,7 +158,7 @@ is_uptodate()
143158 else
144159 # Remote image optimization: check config-sha256 only
145160 if podman container exists " $name " ; then
146- config_sha=$( calc_sha " $script " )
161+ config_sha=$( calc_config_sha " $script " )
147162 container_sha=$( podman inspect " $name " --format ' {{index .Config.Labels "config-sha256"}}' 2> /dev/null)
148163
149164 if [ " $container_sha " = " $config_sha " ]; then
@@ -459,7 +474,7 @@ create()
459474 fi
460475
461476 # Add config checksum label
462- args=" $args --label config-sha256=$( calc_sha " $script " ) "
477+ args=" $args --label config-sha256=$( calc_config_sha " $script " ) "
463478 fi
464479
465480 # shellcheck disable=SC2048
0 commit comments