Skip to content

Commit

Permalink
feat(docker-build): add way to use Docker BuildKit
Browse files Browse the repository at this point in the history
  • Loading branch information
Karol Sójko committed Mar 29, 2023
1 parent c4d0a44 commit 3fec9f9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/docker-build/README.md
Expand Up @@ -72,3 +72,7 @@ Copy additional files to a Docker image. This is useful for secret keys or confi
#### `--production`

Install production dependencies only.

#### `--buildkit`

Build the Docker image using Docker BuildKit, please check the Docker docs for more info: https://docs.docker.com/engine/reference/commandline/buildx_build/
11 changes: 10 additions & 1 deletion packages/docker-build/src/commands/build.ts
Expand Up @@ -39,6 +39,9 @@ export default class DockerBuildCommand extends BaseCommand {
@Command.Boolean('--production')
public production?: boolean;

@Command.Boolean('--buildkit')
public buildKit?: boolean;

public static usage = Command.Usage({
category: 'Docker-related commands',
description: 'Build a Docker image for a workspace',
Expand All @@ -65,6 +68,10 @@ export default class DockerBuildCommand extends BaseCommand {
'Install production dependencies only',
'yarn docker build --production @foo/bar',
],
[
'Build a Docker image using BuildKit',
'yarn docker build --buildkit @foo/bar',
],
],
});

Expand Down Expand Up @@ -200,9 +207,11 @@ export default class DockerBuildCommand extends BaseCommand {
);
}

const buildCommand = this.buildKit ? 'buildx build' : 'build';

await execUtils.pipevp(
'docker',
['build', ...this.args, '-f', dockerFilePath, '.'],
[buildCommand, ...this.args, '-f', dockerFilePath, '.'],
{
cwd,
strict: true,
Expand Down

0 comments on commit 3fec9f9

Please sign in to comment.