# Build & Deployment

## Build Your Container

### Option 1: Snarkify command (recommended)

Simply run:

```
snarkify build
```

* To build from a sub-directory, simply use the `--base_dir={path_to_sub_dir}` option.

{% hint style="warning" %}
Heads up! The first build is like brewing a fine cup of coffee—it takes a bit longer, but it's worth the wait. Patience is a virtue, and great things are brewing!
{% endhint %}

### Option 2: Docker command

Alternatively, it's also possible to use native `docker` command to build your image by following these steps:

1. Have a Dockerfile ready to build your code. Here is a template Dockerfile to invoke the snarkify binary.

```
# Use a smaller, specific version of the Rust image for building
FROM --platform=linux/amd64 rust:latest AS builder

# Create a new empty project
RUN USER=root cargo new --bin snarkify
WORKDIR /snarkify

# Copy over your manifests
COPY ./Cargo.lock ./Cargo.toml ./

# Cache dependencies by building a dummy project
RUN cargo build --release && \
    rm src/*.rs && \
    rm ./target/release/deps/snarkify*

# Build your project for release
COPY ./src ./src
RUN cargo build --release

# Use a slim variant for the runtime stage to reduce size
FROM --platform=linux/amd64 ubuntu:22.04

# Copy the build artifact from the build stage
COPY --from=builder /snarkify/target/release/snarkify /usr/local/bin/snarkify


# Set the startup command to run your binary
CMD ["/usr/local/bin/snarkify"]
```

2. Use docker command to build an image

```
docker build -t {your_image_name} .
```

## Deploy Your Container&#x20;

Once your Docker image has been successfully built, you're just one step away from launching your service. To proceed, simply execute the following command:

```
snarkify deploy
```

* You can assign a unique tag to each deployment for easy reference by using the `--tag` option.
* Should you need to set environment variables, you can conveniently update them using the `--env` flag. For example, `snarkify deploy --env foo=bar --env hello=aloha`.
* If you use the second option (Docker command) to build your image, you need to specify the image using `--image` option.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.snarkify.io/serverless-gpu-proving/snakrify-cli/build-and-deployment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
