Skip to content

Commit

Permalink
feat(docker-build): Add --production option
Browse files Browse the repository at this point in the history
  • Loading branch information
tommy351 committed Mar 23, 2022
1 parent bafbf18 commit 5963d44
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/docker-build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,7 @@ Path to `Dockerfile`. Default to the Dockerfile in the workspace or the project.
#### `--copy`

Copy additional files to a Docker image. This is useful for secret keys or configuration files. The files will be copied to `manifests` folder. The path can be either a path relative to the Dockerfile or an absolute path.

#### `--production`

Install production dependencies only.
11 changes: 9 additions & 2 deletions packages/docker-build/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,14 @@ export default class DockerBuildCommand extends BaseCommand {
@Command.Array('--copy')
public copyFiles?: string[];

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

public static usage = Command.Usage({
category: 'Docker-related commands',
description: 'Build a Docker image for a workspace',
details: `
This command will build a efficient Docker image which only contains production dependencies for the specified workspace.
This command will build a efficient Docker image which only contains necessary dependencies for the specified workspace.
You have to create a Dockerfile in your workspace or your project. You can also specify the path to Dockerfile using the "-f, --file" option.
Expand All @@ -58,6 +61,10 @@ export default class DockerBuildCommand extends BaseCommand {
'Copy additional files to a Docker image',
'yarn docker build --copy secret.key --copy config.json @foo/bar',
],
[
'Install production dependencies only',
'yarn docker build --production @foo/bar',
],
],
});

Expand All @@ -76,7 +83,7 @@ export default class DockerBuildCommand extends BaseCommand {
const requiredWorkspaces = getRequiredWorkspaces({
project,
workspaces: [workspace],
production: true,
production: this.production,
});

const dockerFilePath = await getDockerFilePath(
Expand Down

0 comments on commit 5963d44

Please sign in to comment.