File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed
terraform/modules/run-service Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -18,15 +18,14 @@ provider "docker" {
1818 }
1919}
2020
21- # Calculate hash of source files to determine if rebuild is needed
22- locals {
23- source_files = fileset (path. root , " ${ var . source_directory } /*" )
24- source_hash = substr (sha1 (join (" " , [for f in local . source_files : filesha1 (f)])), 0 , 8 )
21+ # Calculate hash of source files using git (respects .gitignore)
22+ data "external" "source_hash" {
23+ program = [" bash" , " -c" , " cd ${ var . source_directory } && echo '{\" hash\" :\" '$(git ls-files -s | sha1sum | cut -c1-8)'\" }'" ]
2524}
2625
2726# Build Docker image
2827resource "docker_image" "function_image" {
29- name = " ${ var . region } -docker.pkg.dev/${ var . project } /report-api/${ var . service_name } :${ local . source_hash } "
28+ name = " ${ var . region } -docker.pkg.dev/${ var . project } /report-api/${ var . service_name } :${ data . external . source_hash . result . hash } "
3029
3130 build {
3231 context = var. source_directory
You can’t perform that action at this time.
0 commit comments