A dockerized rust http server, it implements an endpoint using tinyapi for image compression.
- Caching support by cargo-chef
- Minimal image size and runtime by distroless
- Cargo registry configured under
.cargo/config.toml
We need get the target name when building rust application, you can set the target name from cli:
docker build --build-arg BUILD_TARGET=image-compress -t rust-http-demo .
or update the first line in the Dockerfile
:
ARG BUILD_TARGET=image-compress
Get tiny api key from the official doc
docker run -p 8080:8080 -e TINY_API_KEY=<YOUR KEY> rust-http-demo
Health check:
curl http://localhost:8080/health
Compress:
curl -X POST --data-binary @image.jpg http://localhost:8080/compress -OJ
Cargo registry was changed for China users, if yor network works well with the default cargo registry, you can remove source
config in the .cargo/config.toml
file.