Skip to content

Commit aa303d0

Browse files
authored
fix: run docker with the --user argument (#659)
This fixes generated clients being owned by root when using runDocker
1 parent f937ecc commit aa303d0

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

apps/generator-cli/src/app/services/generator.service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import * as path from 'path';
66
import * as fs from 'fs-extra';
77
import * as glob from 'glob';
88
import * as chalk from 'chalk';
9+
import * as os from 'os';
910
import {VersionManagerService} from './version-manager.service';
1011
import {ConfigService} from './config.service';
1112
import {LOGGER} from '../constants';
@@ -173,9 +174,12 @@ export class GeneratorService {
173174

174175
if (this.configService.useDocker) {
175176
const volumes = Object.entries(dockerVolumes).map(([k, v]) => `-v "${v}:${k}"`).join(' ');
177+
const userInfo = os.userInfo();
178+
const userArg = userInfo.uid !== -1 ? `--user ${userInfo.uid}:${userInfo.gid}` : ``;
176179

177180
return [
178181
`docker run --rm`,
182+
userArg,
179183
volumes,
180184
this.versionManager.getDockerImageName(),
181185
'generate',

0 commit comments

Comments
 (0)