I have tried to deploy an API written in Rust ( Axum Framework ) but I get the error below, how do I accomplish this, there is no official documentation on this.
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
-----> Cleaning up...
-----> Building api from herokuish
-----> Adding BUILD_ENV to build environment...
BUILD_ENV added successfully
-----> Unable to select a buildpack
remote: ! Failure during app build
remote: ! Removing invalid image tag dokku/api:latest
remote: ! App build failed
I tried adding a Dockerfile but I still get the same Error.
I have managed to deploy by updating the custom Dockerfile and Introduced Procfile with contents bellow:- Also I noticed the app must run on port 5000 to be exposed, unless you change the configurations.
Dockerfile
# Use the official Rust image as the base image FROM rust:bookworm as builder # Set the working directory inside the container WORKDIR /usr/src/app ENV SQLX_OFFLINE=true # Copy the Cargo.toml and Cargo.lock files to the working directory COPY Cargo.toml Cargo.lock ./ # Build dependencies to cache them RUN mkdir src && \ echo "fn main() {}" > src/main.rs && \ cargo build --release && \ rm -rf src # Copy the rest of your source code COPY . . # Build your Rust application RUN cargo build --release # Create a new lightweight image without the build dependencies FROM debian:bookworm-slim RUN apt-get update && apt install -y openssl # Set the working directory inside the container WORKDIR /usr/src/app # Copy the built binary from the builder stage COPY --from=builder /usr/src/app/target/release/main ./ COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt # Expose any necessary ports EXPOSE 5000 # Command to run your application CMD ["./main"]
Procfile
web: ./main