feat(scaffolder): Default the user and group id to the same as the host process for docker reasons
This commit is contained in:
@@ -126,6 +126,25 @@ describe('helpers', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should pass through the user and group id from the host machine', async () => {
|
||||
await runDockerContainer({
|
||||
imageName,
|
||||
args,
|
||||
templateDir,
|
||||
resultDir,
|
||||
dockerClient: mockDocker,
|
||||
});
|
||||
|
||||
expect(mockDocker.run).toHaveBeenCalledWith(
|
||||
imageName,
|
||||
args,
|
||||
expect.any(Stream),
|
||||
expect.objectContaining({
|
||||
User: `${process.getuid()}:${process.getgid()}`,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('should pass through the log stream to the docker client', async () => {
|
||||
const logStream = new PassThrough();
|
||||
await runDockerContainer({
|
||||
|
||||
@@ -72,6 +72,10 @@ export const runDockerContainer = async ({
|
||||
});
|
||||
});
|
||||
|
||||
// Files that are created inside the Docker container will be owned by
|
||||
// root on the host system on non Mac systems, because of reasons. Mainly the fact that
|
||||
// volume sharing is done using NFS on Mac and actual mounts in Linux world.
|
||||
// So we set the user in the container as the same user and group id as the host.
|
||||
const User = `${process.getuid()}:${process.getgid()}`;
|
||||
|
||||
const [{ Error: error, StatusCode: statusCode }] = await dockerClient.run(
|
||||
|
||||
Reference in New Issue
Block a user