mirror of
https://github.com/renovatebot/github-action.git
synced 2025-12-16 17:02:36 +00:00
feat: use slim image (#61)
- mount docker.sock and /tmp to renovate - use slim image Co-authored-by: Jeroen de Bruijn <vidavidorra+jdbruijn@gmail.com> Co-authored-by: Jeroen de Bruijn <62570005+jdbruijn@users.noreply.github.com>
This commit is contained in:
parent
ea9e7f263f
commit
9b8645713e
2 changed files with 27 additions and 1 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
class Docker {
|
class Docker {
|
||||||
readonly repository = 'renovate/renovate';
|
readonly repository = 'renovate/renovate';
|
||||||
// renovate: datasource=docker depName=renovate/renovate versioning=docker
|
// renovate: datasource=docker depName=renovate/renovate versioning=docker
|
||||||
readonly tag = '19.231.12';
|
readonly tag = '19.231.12-slim';
|
||||||
|
|
||||||
image(): string {
|
image(): string {
|
||||||
return `${this.repository}:${this.tag}`;
|
return `${this.repository}:${this.tag}`;
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,16 @@ class Renovate {
|
||||||
}
|
}
|
||||||
|
|
||||||
async runDockerContainer(): Promise<void> {
|
async runDockerContainer(): Promise<void> {
|
||||||
|
const renovateDockerUser = 'ubuntu';
|
||||||
|
const githubActionsDockerGroupId = this.getDockerGroupId();
|
||||||
const commandArguments = [
|
const commandArguments = [
|
||||||
'--rm',
|
'--rm',
|
||||||
`--env ${this.configFileEnv}=${this.configFileMountPath()}`,
|
`--env ${this.configFileEnv}=${this.configFileMountPath()}`,
|
||||||
`--env ${this.tokenEnv}=${this.token}`,
|
`--env ${this.tokenEnv}=${this.token}`,
|
||||||
`--volume ${this.configFile}:${this.configFileMountPath()}`,
|
`--volume ${this.configFile}:${this.configFileMountPath()}`,
|
||||||
|
`--volume /var/run/docker.sock:/var/run/docker.sock`,
|
||||||
|
`--volume /tmp:/tmp`,
|
||||||
|
`--user ${renovateDockerUser}:${githubActionsDockerGroupId}`,
|
||||||
this.docker.image(),
|
this.docker.image(),
|
||||||
];
|
];
|
||||||
const command = `docker run ${commandArguments.join(' ')}`;
|
const command = `docker run ${commandArguments.join(' ')}`;
|
||||||
|
|
@ -35,6 +40,27 @@ class Renovate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch the host docker group of the GitHub Action runner.
|
||||||
|
*
|
||||||
|
* The Renovate container needs access to this group in order to have the
|
||||||
|
* required permissions on the Docker socket.
|
||||||
|
*/
|
||||||
|
private getDockerGroupId(): string {
|
||||||
|
const groups = fs.readFileSync('/etc/group', {
|
||||||
|
encoding: 'utf-8',
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The group file has `groupname:group-password:GID:username-list` as
|
||||||
|
* structure and we're interested in the `GID` (the group ID).
|
||||||
|
*
|
||||||
|
* Source: https://www.thegeekdiary.com/etcgroup-file-explained/
|
||||||
|
*/
|
||||||
|
const [, group] = /^docker:x:([1-9][0-9]*):$/m.exec(groups);
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
private validateArguments(): void {
|
private validateArguments(): void {
|
||||||
if (!fs.existsSync(this.configFile)) {
|
if (!fs.existsSync(this.configFile)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue