@@ -624,9 +624,9 @@ func (d *LocalRunner) toDockerComposeService(s *service) (map[string]interface{}
624
624
625
625
// create the bind volumes
626
626
for localPath , volumeName := range s .volumesMapped {
627
- volumeDirAbsPath , err := d .out . CreateDir ( fmt . Sprintf ( "volume-%s-%s" , s .Name , volumeName ) )
627
+ volumeDirAbsPath , err := d .createVolume ( s .Name , volumeName )
628
628
if err != nil {
629
- return nil , fmt . Errorf ( "failed to create volume dir %s: %w" , volumeName , err )
629
+ return nil , err
630
630
}
631
631
volumes [volumeDirAbsPath ] = localPath
632
632
}
@@ -765,6 +765,15 @@ func (d *LocalRunner) generateDockerCompose() ([]byte, error) {
765
765
return yamlData , nil
766
766
}
767
767
768
+ func (d * LocalRunner ) createVolume (service , volumeName string ) (string , error ) {
769
+ // create the volume in the output folder
770
+ volumeDirAbsPath , err := d .out .CreateDir (fmt .Sprintf ("volume-%s-%s" , service , volumeName ))
771
+ if err != nil {
772
+ return "" , fmt .Errorf ("failed to create volume dir %s: %w" , volumeName , err )
773
+ }
774
+ return volumeDirAbsPath , nil
775
+ }
776
+
768
777
// runOnHost runs the service on the host machine
769
778
func (d * LocalRunner ) runOnHost (ss * service ) error {
770
779
// TODO: Use env vars in host processes
@@ -773,6 +782,34 @@ func (d *LocalRunner) runOnHost(ss *service) error {
773
782
return fmt .Errorf ("failed to apply template, err: %w" , err )
774
783
}
775
784
785
+ // Create the volumes for this service
786
+ volumesMapped := map [string ]string {}
787
+ for pathInDocker , volumeName := range ss .volumesMapped {
788
+ volumeDirAbsPath , err := d .createVolume (ss .Name , volumeName )
789
+ if err != nil {
790
+ return err
791
+ }
792
+ volumesMapped [pathInDocker ] = volumeDirAbsPath
793
+ }
794
+
795
+ // We have to replace the names of the files it is using as artifacts for the full names
796
+ // Just a string replacement should be enough
797
+ for i , arg := range args {
798
+ // If any of the args contains any of the files mapped, we need to replace it
799
+ for pathInDocker , artifactName := range ss .filesMapped {
800
+ if strings .Contains (arg , pathInDocker ) {
801
+ args [i ] = strings .ReplaceAll (arg , pathInDocker , filepath .Join (d .out .dst , artifactName ))
802
+ }
803
+ }
804
+ // If any of the args contains any of the volumes mapped, we need to create
805
+ // the volume and replace it
806
+ for pathInDocker , volumeAbsPath := range volumesMapped {
807
+ if strings .Contains (arg , pathInDocker ) {
808
+ args [i ] = strings .ReplaceAll (arg , pathInDocker , volumeAbsPath )
809
+ }
810
+ }
811
+ }
812
+
776
813
execPath := d .overrides [ss .Name ]
777
814
cmd := exec .Command (execPath , args ... )
778
815
0 commit comments