#Trailing slash in destination path results in strange behaviour

1 messages · Page 1 of 1 (latest)

vale summit
#

Version: 0.15.1
The trailing slash in the destination path of withFile in containerB results in the file having the name of the destination directory.
Shouldn't the output of containerB and containerC be the same?
Code:

import { connect } from '@dagger.io/dagger';

async function main() {
  await connect(async (client) => {
    const containerA = client.container().from('alpine').withWorkdir('/app').withExec(['touch', 'a']);
    const containerB = client
      .container()
      .from('alpine')
      .withWorkdir('/app')
      .withFile('/app/', containerA.file('/app/a'));
    const containerC = client
      .container()
      .from('alpine')
      .withWorkdir('/app')
      .withFile('/app/a', containerA.file('/app/a'));
    console.log(await containerB.withExec(['tree', '/app']).stdout());
    console.log(await containerC.withExec(['tree', '/app']).stdout());
  });
}

main();

Output:

/app
└── app

0 directories, 1 files

/app
└── a

0 directories, 1 files
hollow quiver
vale summit
#

Also the trailing slash should indicate to create it in the directory in the first place.

hollow quiver
#

🤷‍♂️. I'd assume this probably has a long and interesting discussion in the Docker world, lol

vale summit