Build & Deployment

Build Your Container

Simply run:

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

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!

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"]
  1. Use docker command to build an image

docker build -t {your_image_name} .

Deploy Your Container

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.

Last updated