I've not always been keen on docker but I wanted to give a try at running Finch's API inside a container. Thanks to Alpine Linux images I was able to create a container only 9MB in size that can run my Rust API server.
I'm going to keep this around so that whenever I open source this folks can use it. Personally I'm not sure if I'd want to use Docker or just copy the executable to a server and run it.
Dockerfile below the fold for those who are curious.
# Builder container first
FROM rust:1.76.0-alpine3.19 as builder
WORKDIR /usr/src/finch
COPY src/ ./src
COPY Cargo.lock .
COPY Cargo.toml .
RUN apk add --no-cache musl-dev
RUN cargo install --path .
RUN strip /usr/local/cargo/bin/finch
# Then our runtime container
FROM alpine:3.19
WORKDIR /finch
COPY --from=builder /usr/local/cargo/bin/finch /usr/local/bin/finch
EXPOSE 3000
CMD ["finch"]
made with @nex3's syntax highlighter
