Build & Deployment
Build Your Container
Option 1: Snarkify command (recommended)
Simply run:
snarkify buildTo 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:
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"]Use docker command to build an image
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:
You can assign a unique tag to each deployment for easy reference by using the
--tagoption.Should you need to set environment variables, you can conveniently update them using the
--envflag. 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
--imageoption.
Last updated