Skip to content

Commit

Permalink
fix: run docker with the --user argument (#659)
Browse files Browse the repository at this point in the history
This fixes generated clients being owned by root when using runDocker
  • Loading branch information
kageurufu committed Sep 5, 2022
1 parent f937ecc commit aa303d0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apps/generator-cli/src/app/services/generator.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as path from 'path';
import * as fs from 'fs-extra';
import * as glob from 'glob';
import * as chalk from 'chalk';
import * as os from 'os';
import {VersionManagerService} from './version-manager.service';
import {ConfigService} from './config.service';
import {LOGGER} from '../constants';
Expand Down Expand Up @@ -173,9 +174,12 @@ export class GeneratorService {

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

return [
`docker run --rm`,
userArg,
volumes,
this.versionManager.getDockerImageName(),
'generate',
Expand Down

0 comments on commit aa303d0

Please sign in to comment.