diff --git a/Dockerfile b/Dockerfile index 71840fb..959c666 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM rust:1.67.0-buster as builder +FROM rust:1.85-bookworm as builder WORKDIR /usr/src/app @@ -7,7 +7,9 @@ COPY . . RUN cargo build --release # Now copy it into our base image. -FROM gcr.io/distroless/cc-debian10 +FROM gcr.io/distroless/cc-debian12:nonroot COPY --from=builder /usr/src/app/target/release/rust-tokenizers-api /usr/local/bin/rust-tokenizers-api -CMD ["rust-tokenizers-api"] +EXPOSE 8000 +USER nonroot:nonroot +ENTRYPOINT ["/usr/local/bin/rust-tokenizers-api"] \ No newline at end of file diff --git a/README.md b/README.md index 0b1ae95..5b4c87c 100644 --- a/README.md +++ b/README.md @@ -72,3 +72,14 @@ Note that it is a good practice to use `404 Not Found` to protect from requests | GET | POST | PUT | HEAD| |---|---|---|---| | Read Only | Write Only | Update existing | Does it exist? | + + +### HOW TO USE: +docker build . -t local-rust-distroless +docker images | grep local-rust-distroless +docker run -p 8000:8000 local-rust-distroless + +#### In a different terminal +curl -X POST --data '{"text": "some text"}' --header "Content-Type: application/json" http://localhost:8000/tokenizers/bert-base-cased + +curl -X POST --data '{"text": "some text"}' --header "Content-Type: application/json" http://localhost:8000/tokenizers/bert-base-uncased \ No newline at end of file