Skip to content

Commit

Permalink
fix(binary-builder): pass args to image builder (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice committed Feb 8, 2021
1 parent 916585a commit a4c51ec
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 450 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ jobs:
config: e2e/python.json
dry-run: true
token: ${{ github.token }}
build-args: 'FLAVOR=focal'

- name: dummy-command
uses: ./
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ ARG PYTHON_VERSION=3.7.7
# renovate: datasource=github-releases depName=helm/helm
ARG HELM_VERSION=3.4.0

ENTRYPOINT [ "echo" ]
ARG FLAVOR=latest
RUN echo FLAVOR=$FLAVOR
ENTRYPOINT ["echo" ]
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"scripts": {
"clean": "rm -rf dist",
"compile": "cd src && ncc build ./index.ts -o ../dist",
"compile": "cd src && ncc build ./index.ts -o ../dist -s",
"eslint": "eslint .",
"eslint:fix": "yarn eslint --fix",
"lint": "run-s eslint prettier",
Expand All @@ -35,7 +35,6 @@
"renovate": "24.42.1",
"semver": "7.3.4",
"shelljs": "0.8.4",
"source-map-support": "0.5.19",
"strip-ansi": "6.0.0",
"www-authenticate": "0.6.2"
},
Expand All @@ -50,7 +49,7 @@
"@types/shelljs": "0.8.8",
"@typescript-eslint/eslint-plugin": "4.6.0",
"@typescript-eslint/parser": "4.6.0",
"@zeit/ncc": "0.22.3",
"@vercel/ncc": "0.27.0",
"conventional-changelog-conventionalcommits": "4.5.0",
"eslint": "7.12.1",
"eslint-config-prettier": "6.15.0",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/binary/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export async function run(): Promise<void> {

shell.mkdir('-p', `${ws}/.cache`);

await createBuilderImage(ws);
await createBuilderImage(ws, cfg);

for (const version of versions) {
await updateRelease(api, cfg, version);
Expand Down
26 changes: 13 additions & 13 deletions src/commands/binary/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getArg, getUbuntuFlavor, isDryRun, readJson } from '../../util';
import is from '@sindresorhus/is';
import { getArg, isDryRun, readJson } from '../../util';
import { readDockerConfig } from '../../utils/config';
import { dockerBuildx } from '../../utils/docker/common';
import log from '../../utils/logger';
Expand All @@ -14,19 +15,18 @@ export async function getConfig(file: string): Promise<BinaryBuilderConfig> {
ignoredVersions: cfg.ignoredVersions ?? [],
dryRun: isDryRun(),
lastOnly: getArg('last-only') == 'true',
buildArgs: getArg('build-args', { multi: true }),
} as BinaryBuilderConfig;
}

export async function createBuilderImage(ws: string): Promise<void> {
const flavor = getUbuntuFlavor();
log('Creating builder for flavor', flavor);
await dockerBuildx(
'build',
'--load',
'-t',
'builder',
'--build-arg',
flavor,
ws
);
export async function createBuilderImage(
ws: string,
{ buildArgs }: BinaryBuilderConfig
): Promise<void> {
log('Creating builder image');
const args = ['build', '--load', '-t', 'builder'];
if (is.nonEmptyArray(buildArgs)) {
args.push(...buildArgs.map((b) => `--build-arg=${b}`));
}
await dockerBuildx(...args, ws);
}
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'source-map-support/register';
import run from './runner';

run().catch(console.error);
1 change: 1 addition & 0 deletions src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export type Config = {
} & ConfigFile;

export type BinaryBuilderConfig = {
buildArgs?: string[];
depName: string;
ignoredVersions: string[];
lastOnly: boolean;
Expand Down

0 comments on commit a4c51ec

Please sign in to comment.