ion
ion copied to clipboard
cluster service does not properly support absolute context paths
Original issue is here: https://github.com/sst/ion/issues/424 this was closed prematurely without fixing the bug I was experiencing.
if you create a cluster like this:
cluster.addService("MyService", {
image: {
context: '/Users/foobar/code/experiments/sst-cluster',
dockerfile: '/Users/foobar/code/experiments/sst-cluster/infra/test/Dockerfile'
}
});
Where the context/dockerfile paths are absolute, and the Dockerfile is in a subpath of the context then sst deploy fails with:
× Failed
Error: ENOENT: no such file or directory, open '/Users/foobar/code/experiments/sst-cluster/infra/Users/foobar/code/experiments/sst-cluster/.dockerignore'
at Object.writeFileSync (node:fs:2352:20)
at file:///Users/foobar/code/experiments/sst-cluster/infra/.sst/platform/src/components/aws/service.ts:292:14
at /Users/foobar/code/experiments/sst-cluster/infra/.sst/platform/node_modules/@pulumi/output.ts:404:31
at Generator.next (<anonymous>)
at /Users/foobar/code/experiments/sst-cluster/infra/.sst/platform/node_modules/@pulumi/pulumi/output.js:21:71
at new Promise (<anonymous>)
at __awaiter (/Users/foobar/code/experiments/sst-cluster/infra/.sst/platform/node_modules/@pulumi/pulumi/output.js:17:12)
at applyHelperAsync (/Users/foobar/code/experiments/sst-cluster/infra/.sst/platform/node_modules/@pulumi/pulumi/output.js:245:12)
at /Users/foobar/code/experiments/sst-cluster/infra/.sst/platform/node_modules/@pulumi/output.ts:316:13 {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '/Users/foobar/code/experiments/sst-cluster/infra/Users/foobar/code/experiments/sst-cluster/.dockerignore',
promise: Promise { <rejected> [Circular *1] }
}
Docker allows context paths which do not have to be in a sub-directory relative to the dockefile, they can be parent directories or the Dockerfile and context can be separated. A docker context must be absolute if it is not a sub-directory, e.g. ../
is not a valid context.
Currently SST assumes the context will be in a relative position to the $cli.paths.root
, this may not be the same root of the project in all cases, e.g. a monorepo where the modules are hoisted to a parent package.json
.
Currently it is not possible to deploy a service having a context with an absolute path which is a parent directory of the sst.config.ts
.