[id="osdk-cli-reference-build_{context}"]
= build

The `operator-sdk build` command compiles the code and builds the executables.
After `build` completes, the image is built locally in `docker`. It must then be
pushed to a remote registry.

.`build` arguments
[options="header",cols="1,3"]
|===
|Argument |Description

|`<image>`
|The container image to be built, e.g., `quay.io/example/operator:v0.0.1`.
|===

.`build` flags
[options="header",cols="1,3"]
|===
|Flag |Description

|`--enable-tests` (bool)
|Enable in-cluster testing by adding test binary to the image.

|`--namespaced-manifest` (string)
|Path of namespaced resources manifest for tests. Default: `deploy/operator.yaml`.

|`--test-location` (string)
|Location of tests. Default: `./test/e2e`

|`-h, --help`
|Usage help output.
|===

If `--enable-tests` is set, the `build` command also builds the testing binary,
adds it to the container image, and generates a `deploy/test-pod.yaml` file that
allows a user to run the tests as a Pod on a cluster.

For example:

[source,terminal]
----
$ operator-sdk build quay.io/example/operator:v0.0.1
----

.Example output
[source,terminal]
----
building example-operator...

building container quay.io/example/operator:v0.0.1...
Sending build context to Docker daemon  163.9MB
Step 1/4 : FROM alpine:3.6
 ---> 77144d8c6bdc
Step 2/4 : ADD tmp/_output/bin/example-operator /usr/local/bin/example-operator
 ---> 2ada0d6ca93c
Step 3/4 : RUN adduser -D example-operator
 ---> Running in 34b4bb507c14
Removing intermediate container 34b4bb507c14
 ---> c671ec1cff03
Step 4/4 : USER example-operator
 ---> Running in bd336926317c
Removing intermediate container bd336926317c
 ---> d6b58a0fcb8c
Successfully built d6b58a0fcb8c
Successfully tagged quay.io/example/operator:v0.0.1
----
