# Builds the `hello` example and ships it as a runnable demo.
#
# This image is NOT the package. Joist is a library, and the library lives on
# crates.io as `joist`. The image exists so the example service can be run
# without installing a Rust toolchain, and so the project is visible under the
# repository's Packages, which has no registry for Cargo crates.
#
# docker run --rm -p 8080:8080 ghcr.io/martin-k-m/joist
# curl localhost:8080/hello/martin
FROM rust:1-alpine AS build
RUN apk add --no-cache musl-dev
WORKDIR /src
COPY . .
RUN cargo build --release --example hello
FROM alpine:3.20
LABEL org.opencontainers.image.source="https://github.com/martin-k-m/joist" \
org.opencontainers.image.description="Runnable demo of the joist backend framework" \
org.opencontainers.image.licenses="Apache-2.0"
COPY --from=build /src/target/release/examples/hello /usr/local/bin/joist-hello
# 127.0.0.1 inside a container is only reachable from inside it.
ENV APP_HOST=0.0.0.0
ENV APP_PORT=8080
EXPOSE 8080
ENTRYPOINT ["joist-hello"]