diff --git a/src/renovate.ts b/src/renovate.ts index a3354764..ea09dcb7 100644 --- a/src/renovate.ts +++ b/src/renovate.ts @@ -20,11 +20,7 @@ class Renovate { } async runDockerContainer(): Promise { - const groups = await fs.promises.readFile('/etc/group', { - encoding: 'utf-8', - }); - const [, group] = /^docker:x:([1-9][0-9]*):$/m.exec(groups); - // await exec('sudo', ['chmod', 'o=rw', '/var/run/docker.sock']); + const group = await this.getDockerGroup(); const commandArguments = [ '--rm', `--env ${this.configFileEnv}=${this.configFileMountPath()}`, @@ -43,6 +39,18 @@ class Renovate { } } + /** + * Fetch the host docker group on github. + * Container user needs this to access the docker socket. + */ + private async getDockerGroup(): Promise { + const groups = await fs.promises.readFile('/etc/group', { + encoding: 'utf-8', + }); + const [, group] = /^docker:x:([1-9][0-9]*):$/m.exec(groups); + return group; + } + private validateArguments(): void { if (!fs.existsSync(this.configFile)) { throw new Error(