Skip to content

Commit

Permalink
feat(container): add extraFlags option for docker builder
Browse files Browse the repository at this point in the history
* feat(core): add docker command flags

allow the user to add in more flags to docker build such as ssh.

* feat(core): change to extraflags based on pr feedback

update commandargs to extraflags

* fix: build error after merge from master (TBS)
  • Loading branch information
edvald authored Aug 5, 2019
1 parent 19a5465 commit 2a74068
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/reference/module-types/container.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,14 @@ Specify build arguments to use when building the container image.
| -------- | -------- | ------- |
| `object` | No | `{}` |

### `extraFlags`

Specify extra flags to use when building the container image. Note that arguments may not be portable across implementations.

| Type | Required |
| --------------- | -------- |
| `array[string]` | No |

### `image`

Specify the image name for the container. Should be a valid Docker image identifier. If specified and the module does not contain a Dockerfile, this image will be used to deploy services for this module. If specified and the module does contain a Dockerfile, this identifier is used when pushing the built image.
Expand Down Expand Up @@ -962,6 +970,7 @@ build:
target: <same as source path>
targetImage:
buildArgs: {}
extraFlags:
image:
hotReload:
sync:
Expand Down
9 changes: 9 additions & 0 deletions docs/reference/module-types/maven-container.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,14 @@ Specify build arguments to use when building the container image.
| -------- | -------- | ------- |
| `object` | No | `{}` |

### `extraFlags`

Specify extra flags to use when building the container image. Note that arguments may not be portable across implementations.

| Type | Required |
| --------------- | -------- |
| `array[string]` | No |

### `image`

Specify the image name for the container. Should be a valid Docker image identifier. If specified and the module does not contain a Dockerfile, this image will be used to deploy services for this module. If specified and the module does contain a Dockerfile, this identifier is used when pushing the built image.
Expand Down Expand Up @@ -997,6 +1005,7 @@ build:
target: <same as source path>
targetImage:
buildArgs: {}
extraFlags:
image:
hotReload:
sync:
Expand Down
2 changes: 2 additions & 0 deletions garden-service/src/plugins/container/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ export async function buildContainerModule({ module, log }: BuildModuleParams<Co

const cmdOpts = ["build", "-t", identifier, ...getDockerBuildFlags(module)]

cmdOpts.push(...module.spec.extraFlags || [])

if (module.spec.dockerfile) {
cmdOpts.push("--file", containerHelpers.getDockerfileBuildPath(module))
}
Expand Down
7 changes: 7 additions & 0 deletions garden-service/src/plugins/container/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ export interface ContainerBuildSpec extends BaseBuildSpec {
export interface ContainerModuleSpec extends ModuleSpec {
build: ContainerBuildSpec,
buildArgs: PrimitiveMap,
extraFlags: string[],
image?: string,
dockerfile?: string,
hotReload?: ContainerHotReloadSpec,
Expand Down Expand Up @@ -420,6 +421,12 @@ export const containerModuleSpecSchema = joi.object()
.pattern(/.+/, joiPrimitive())
.default(() => ({}), "{}")
.description("Specify build arguments to use when building the container image."),
extraFlags: joi.array()
.items(joi.string())
.description(deline`
Specify extra flags to use when building the container image.
Note that arguments may not be portable across implementations.`,
),
// TODO: validate the image name format
image: joi.string()
.description(deline`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const gardenPlugin = (): GardenPlugin => ({
dependencies: [],
},
buildArgs: {},
extraFlags: [],
services: [],
tasks: [],
tests: [],
Expand Down
1 change: 1 addition & 0 deletions garden-service/src/plugins/openfaas/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export function getContainerModule(module: OpenFaasModule): ContainerModule {
...module.spec,
buildArgs: {},
dockerfile: "Dockerfile",
extraFlags: [],
services: [],
tasks: [],
tests: [],
Expand Down
6 changes: 6 additions & 0 deletions garden-service/test/unit/src/plugins/container/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ describe("plugins.container", () => {
spec: {
build: { dependencies: [] },
buildArgs: {},
extraFlags: [],
services: [],
tasks: [],
tests: [],
Expand Down Expand Up @@ -96,6 +97,7 @@ describe("plugins.container", () => {
spec: {
build: { dependencies: [] },
buildArgs: {},
extraFlags: [],
services: [{
name: "service-a",
annotations: {},
Expand Down Expand Up @@ -173,6 +175,7 @@ describe("plugins.container", () => {
{
build: { dependencies: [] },
buildArgs: {},
extraFlags: [],
services:
[{
name: "service-a",
Expand Down Expand Up @@ -302,6 +305,7 @@ describe("plugins.container", () => {
spec: {
build: { dependencies: [] },
buildArgs: {},
extraFlags: [],
services: [{
name: "service-a",
annotations: {},
Expand Down Expand Up @@ -363,6 +367,7 @@ describe("plugins.container", () => {
spec: {
build: { dependencies: [] },
buildArgs: {},
extraFlags: [],
services: [{
name: "service-a",
annotations: {},
Expand Down Expand Up @@ -418,6 +423,7 @@ describe("plugins.container", () => {
spec: {
build: { dependencies: [] },
buildArgs: {},
extraFlags: [],
services: [{
name: "service-a",
annotations: {},
Expand Down
2 changes: 2 additions & 0 deletions garden-service/test/unit/src/plugins/container/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ describe("containerHelpers", () => {
spec: {
build: { dependencies: [] },
buildArgs: {},
extraFlags: [],
services: [],
tasks: [],
tests: [],
Expand Down Expand Up @@ -233,6 +234,7 @@ describe("containerHelpers", () => {
spec: {
build: { dependencies: [] },
buildArgs: {},
extraFlags: [],
image: "some/image",
services: [],
tasks: [],
Expand Down

0 comments on commit 2a74068

Please sign in to comment.